traceur

Es6简介

青春壹個敷衍的年華 提交于 2021-02-13 21:27:45
ECMAScript 6.0(以下简称 ES6)是 JavaScript 语言的下一代标准,已经在 2015 年 6 月正式发布了。它的目标,是使得 JavaScript 语言可以用来编写复杂的大型应用程序,成为企业级开发语言。 ECMAScript 和 JavaScript 的关系 一个常见的问题是,ECMAScript 和 JavaScript 到底是什么关系? 要讲清楚这个问题,需要回顾历史。1996 年 11 月,JavaScript 的创造者 Netscape 公司,决定将 JavaScript 提交给标准化组织 ECMA,希望这种语言能够成为国际标准。次年,ECMA 发布 262 号标准文件(ECMA-262)的第一版,规定了浏览器脚本语言的标准,并将这种语言称为 ECMAScript,这个版本就是 1.0 版。 该标准从一开始就是针对 JavaScript 语言制定的,但是之所以不叫 JavaScript,有两个原因。一是商标,Java 是 Sun 公司的商标,根据授权协议,只有 Netscape 公司可以合法地使用 JavaScript 这个名字,且 JavaScript 本身也已经被 Netscape 公司注册为商标。二是想体现这门语言的制定者是 ECMA,不是 Netscape,这样有利于保证这门语言的开放性和中立性。 因此,ECMAScript 和

Is it possible to transpile jQuery to Vanilla JS?

北城余情 提交于 2020-12-05 11:53:25
问题 I use traceur / babel to transpile ES6 to ES5 but is it possible to use an gulp plugin to transpile jQuery to plain javascript? Thanks for Your answers :) 回答1: You can open the jquery.js and look for the relevant functions you want to convert to native javascript. Copy it into a new helper.js, include it instead of jquery.js (or jquery.min.js) and use this functions. Voila, native js-functions. 回答2: There is no gulp plugin to transpile jQuery to javascript. This is somewhat related to this

Reference Error: Proxy is Not Defined

泄露秘密 提交于 2020-02-05 13:36:09
问题 I am trying to use ES6 Proxies in an Angular app of mine as so: // Create defensive object using ES6 Proxy createDefensiveObject(target) { return new Proxy(target, { get : (target, property) => { if(property in target) return target[property]; else throw new ReferenceError(`Property \"${property}\" does not exist`); } }); } I am using Traceur to transpile everything in Chrome, and I have experimental JavaScript enabled. All other ES6 features I have implemented are working as expected, but

Using ES6 modules with traceur in single build file

人走茶凉 提交于 2020-01-23 10:11:18
问题 I just have a simple question cant get in any place, heve been googling for it all morning. There is no much info about traceur and when there is is not so clear, at least to me. How should be implemented the ES6 modules when im transpiling with traceur a single output file and using it in the browser with traceur-runtime? import and export keeps getting Unexpected token. I am using gulp-traceur and tried already all the modules options //'commonjs' //'amd', 'commonjs', 'instantiate', 'inline

angularjs http interceptor class (ES6) loses binding to 'this'

孤街浪徒 提交于 2019-12-20 11:51:53
问题 I am building and AngularJS app using ES6 classes with traceur transpiling to ES5 in AMD format. in my module I import the interceptor class and register it as a service, and then register this service with the $httpProvider.interceptors in module.config: var commonModule = angular.module(moduleName, [constants.name]); import authenticationInterceptor from './authentication/authentication.interceptor'; commonModule.service('authenticationInterceptor', authenticationInterceptor); commonModule

angularjs http interceptor class (ES6) loses binding to 'this'

你离开我真会死。 提交于 2019-12-20 11:51:09
问题 I am building and AngularJS app using ES6 classes with traceur transpiling to ES5 in AMD format. in my module I import the interceptor class and register it as a service, and then register this service with the $httpProvider.interceptors in module.config: var commonModule = angular.module(moduleName, [constants.name]); import authenticationInterceptor from './authentication/authentication.interceptor'; commonModule.service('authenticationInterceptor', authenticationInterceptor); commonModule

Extending Array with ES6 classes

随声附和 提交于 2019-12-18 03:54:28
问题 I have heard that ES6 now finally permits subclassing Array. Here's an example given by class Stack extends Array { constructor() { super() } top() { return this[this.length - 1]; } } var s = new Stack(); s.push("world"); s.push("hello"); console.log(s.top()); // "hello" console.log(s.length); // 2 Sure, that works. But in Traceur at least, setting the length explicitly does not truncate the array. And when printing via console.log, the output is in object form rather than array form,

Extending Array with ES6 classes

可紊 提交于 2019-12-18 03:54:27
问题 I have heard that ES6 now finally permits subclassing Array. Here's an example given by class Stack extends Array { constructor() { super() } top() { return this[this.length - 1]; } } var s = new Stack(); s.push("world"); s.push("hello"); console.log(s.top()); // "hello" console.log(s.length); // 2 Sure, that works. But in Traceur at least, setting the length explicitly does not truncate the array. And when printing via console.log, the output is in object form rather than array form,

Nested ES6 classes?

陌路散爱 提交于 2019-12-17 09:35:22
问题 It seems possible to nest a class in a constructor which can then be instantiated from anywhere within the class, is this official? [EDIT] E.g., class C { constructor() { class D { constructor() { } } } method() { var a = new D(); // works fine } } //var a = new D(); // fails in outer scope The traceur generated JS https://google.github.io/traceur-compiler/demo/repl.html $traceurRuntime.ModuleStore.getAnonymousModule(function() { "use strict"; var C = function C() { var D = function D() {}; (

ECMAScript 6: what is WeakSet for?

爱⌒轻易说出口 提交于 2019-12-17 08:46:27
问题 The WeakSet is supposed to store elements by weak reference. That is, if an object is not referenced by anything else, it should be cleaned from the WeakSet. I have written the following test: var weakset = new WeakSet(), numbers = [1, 2, 3]; weakset.add(numbers); weakset.add({name: "Charlie"}); console.log(weakset); numbers = undefined; console.log(weakset); Even though my [1, 2, 3] array is not referenced by anything, it's not being removed from the WeakSet. The console prints: WeakSet {[1,