Contents
  1. 1. ECMAScript
    1. 1.1. delete object property immutably
    2. 1.2. compare array
  2. 2. JSX
    1. 2.1. 使用條件式產生Properties
    2. 2.2. 使用迴圈產生JSX elements
  3. 3. Dojo Toolkit
    1. 3.1. dojo/on
    2. 3.2. Closure
    3. 3.3. Singleton

ECMAScript

delete object property immutably

1
const {[businessToRemove.businessID]: _, ...updatedBusinesses} = savedBusinesses;

compare array

JSX

使用條件式產生Properties

1
<KeyboardAvoidingView {...(Platform.OS === 'ios' && {behavior: 'padding'})}>

使用迴圈產生JSX elements

1
2
3
4
5
<View style={tw`flex-1 justify-around`}>
{notes.map(note => (
<Text key={note.key}>{note.content}</Text>
))}
</View>

Dojo Toolkit

  • with the 1.7 release Dojo adopted the Asynchronous Module Definition (AMD) format for its source code, allowing completely modular web application development.
  • require enables you to load modules and use them, while define allows you to define your own modules. A module is typically a single JavaScript source file.

dojo/on

1
2
3
4
5
require(["dojo/on"], function(on){
on(target, "event", function(e){ /* who, "what", how */
// handle the event
});
});

Closure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
define(function(){
var privateValue = 0;
return {
increment: function(){
privateValue++;
},

decrement: function(){
privateValue--;
},

getValue: function(){
return privateValue;
}
};
});

Singleton

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
define(function(){
var privateValue = 0;
return {
increment: function(){
privateValue++;
},

decrement: function(){
privateValue--;
},

getValue: function(){
return privateValue;
}
};
});

Introduction to AMD Modules

Contents
  1. 1. ECMAScript
    1. 1.1. delete object property immutably
    2. 1.2. compare array
  2. 2. JSX
    1. 2.1. 使用條件式產生Properties
    2. 2.2. 使用迴圈產生JSX elements
  3. 3. Dojo Toolkit
    1. 3.1. dojo/on
    2. 3.2. Closure
    3. 3.3. Singleton