require(["dojo/json"], function(JSON){
var newJson = JSON.parse('{"hello":"world"}'),
jsonString = JSON.stringify(newJson);
});
becomes:
var newJson = JSON.parse('{"hello":"world"}'),
jsonString = JSON.stringify(newJson);
require(["dojo/_base/lang"], function(lang){
var myObj = { foo: "bar" },
func = lang.hitch(myObj, function(){
console.log(this.foo);
});
func();
});
becomes:
var myObj = { foo: "bar" },
func = function(){
console.log(this.foo);
}.bind(myObj);
func();
require([
'dojox/lang/functional/object'
], function(o) {
var obj = {
key: 'value1',
name: 'myName',
numeric: 1,
'hello': 'there'
};
console.log(o.keys(obj));
console.log(o.values(obj));
});
...
becomes:
var obj = {
key: 'value1',
name: 'myName',
numeric: 1,
'hello': 'there'
};
console.log(Object.keys(obj));
//Object.keys(obj).forEach(/*...*/);
require(["dojo/_base/lang"], function(lang){
lang.isArray([1,2]);
});
becomes:
Array.isArray("this will be false");
require(["dojo/_base/array"], function(array){
var arr = [ 1, 2, 3, 4, 5 ];
array.indexOf(arr, 1);
array.lastIndexOf(arr,1);
});
becomes:
var arr = [ 1, 2, 3, 4, 5 ];
arr.indexOf(1);
arr.lastIndexOf(1);
require(["dojo/_base/array"], function(array){
var arr = [ 1, 2, 3, 4, 5 ];
array.forEach(arr, function (element) { console.log(element); });
array.filter(arr, function (element) { return element > 2; }, this)
});
becomes:
var arr = [ 1, 2, 3, 4, 5 ];
arr.some(function (e, index) { return index > 2 && e > 2; }, this);
arr.every(Array.isArray);
require(["dojo/_base/array"], function(array){
var arr = [ 1, 2, 3, 4, 5 ];
array.map(arr, function (element) { return element * element; });
});
becomes:
var arr = [ 1, 2, 3, 4, 5 ];
arr.map(Math.sqrt)
arr.map(parseInt);
require(["dojox/lang/functional/array"], function(array){
var arr = [ [1, 2], [3, 4, 5] ];
array.reduce(arr, function(prev, curr) { return prev + curr; });
});
becomes:
var arr = [ 1, 2, 3, 4, 5 ];
arr.reduceRight(function(a, b) { a.concat(b); });
require(["dojo/_base/lang"], function(lang){
lang.trim(" one\f\n\t");
});
becomes:
" test \n".trim();