This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const merge = require('webpack-merge'); | |
const common = require('./webpack.common.js'); | |
module.exports = merge(common, { | |
mode: 'development', | |
devServer: { | |
contentBase: './dist' | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const CleanWebpackPlugin = require('clean-webpack-plugin'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
module.exports = { | |
entry: { | |
app: './src/index.js' | |
}, | |
module: { | |
rules: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "react-application", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const weakSet = new WeakSet(); | |
const obj = {}; | |
weakSet.add(obj); | |
weakSet.has(obj); | |
// true | |
weakSet.delete(obj); | |
// true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const weakMap = new WeakMap(); | |
let obj = {}; | |
weakMap.set(obj, 11); | |
weakMap.get(obj); | |
// 11 | |
console.log(weakMap); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const weakMap = new WeakMap(); | |
const obj = {}; | |
weakMap.set(obj, 11); | |
weakMap.set(1,1); | |
// Uncaught TypeError: Invalid value used as weak map key | |
weakMap.get(obj); | |
// 11 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In some cases you won't have an access to modify the object. | |
So, what kind of cases they are? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const weakMap = new WeakMap(); // be sure you using custom WeakMap not native | |
const obj = Object.freeze({ hello: true }); | |
weakMap.set(obj, 12); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myMap = new Map(); | |
const arr1 = []; | |
const arr2 = []; | |
myMap.set(arr1, 1); | |
myMap.set(arr2, 2); | |
console.log([...myMap]); | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obj = {}; | |
const arr1 = []; | |
const arr2 = []; | |
obj[arr1] = 1; | |
obj[arr2] = 2; | |
console.log(obj); | |
// {"": 2} |