Moon Light Box

Time is Money

Posts match “ javascript ” tag:

JavaScript - fetch

| Comments

https://github.com/github/fetch

https://github.github.io/fetch/

https://hashnode.com/post/5-best-libraries-for-making-ajax-calls-in-react-cis8x5f7k0jl7th53z68s41k1

https://medium.com/yoniweisbrod/interacting-with-apis-using-react-native-fetch-9733f28566bb#.a6u9kcup5@

http://skychang.github.io/2015/11/02/JavaScript-Use_Javascript_Fetch/

https://www.w3ctech.com/topic/854

https://eyesofkids.gitbooks.io/javascript-start-from-es6/content/part4/ajax_fetch.html

https://blog.othree.net/log/2014/11/25/fetch/

JavaScript - Airbnb ESLint

| Comments

# yarn add -D eslint babel-eslint
# yarn add -D eslint-config-airbnb eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y
# eslint.js --init
? How would you like to configure ESLint? Answer questions about your style
? Are you using ECMAScript 6 features? Yes
? Are you using ES6 modules? Yes
? Where will your code run? Browser, Node
? Do you use CommonJS? No
? Do you use JSX? Yes
? Do you use React? Yes
? What style of indentation do you use? Spaces
? What quotes do you use for strings? Single
? What line endings do you use? Unix
? Do you require semicolons? Yes
? What format do you want your config file to be in? JSON
# vim .eslintrc.json
{
    ...
    "extends": "airbnb",
    ...
    "parser": "babel-eslint",
    ...
    "rules": {
        ...
        "strict": 0
        ...
    }
}

:wq!

https://github.com/babel/babel-eslint

https://github.com/airbnb/javascript

https://denny.qollie.com/2016/07/11/eslint-fxcking-setup/

http://seans.tw/2016/eslint-with-airbnb/

http://le0zh.github.io/2016/06/21/eslint+in+react+babel+webpack/

JavaScript - Install NodeJS in MAC OS

| Comments

Step 1. Install nodejs via NVM.

# touch ./.bash_profile
# curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
# nvm ls-remote 8
# nvm install 8.4.0

Step 2. Install yarn via brew.

# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# brew install yarn

Step 3. Upgrade old yarn version

# brew upgrade yarn

https://github.com/creationix/nvm

JavaScript - == vs ===

| Comments

== will do "implicit type conversion"

var num = 0;
var obj = new String("0");
var str = "0";

console.log(num == num); // true
console.log(obj == obj); // true
console.log(str == str); // true

console.log(num == obj); // true
console.log(num == str); // true
console.log(obj == str); // true
console.log(null == undefined); // true

// 除了少數情況,這兩個應該是 false。
console.log(obj == null);
console.log(obj == undefined);

=== will not do "implicit type conversion"

var num = 0;
var obj = new String("0");
var str = "0";

console.log(num === num); // true
console.log(obj === obj); // true
console.log(str === str); // true

console.log(num === obj); // false
console.log(num === str); // false
console.log(obj === str); // false
console.log(null === undefined); // false
console.log(obj === null); // false
console.log(obj === undefined); // false

https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Equality_comparisons_and_sameness
https://dotblogs.com.tw/alantsai/2013/06/27/106134