티스토리 뷰

■ 프론트엔드 ■/JavaScript

new 연산자를 피하라

SAP (Study And Programming) by serpiko 2018. 1. 26. 16:23

   new 연산자를 피하라


Use {} instead of new Object()

Use "" instead of new String()

Use 0 instead of new Number()

Use false instead of new Boolean()

Use [] instead of new Array()

Use /()/ instead of new RegExp()

Use function (){} instead of new Function()


var x1 = {};           // new object

var x2 = "";           // new primitive string

var x3 = 0;            // new primitive number

var x4 = false;        // new primitive boolean

var x5 = [];           // new array object

var x6 = /()/;         // new regexp object

var x7 = function(){}; // new function object


source)

https://www.w3schools.com/js/js_best_practices.asp

댓글
댓글쓰기 폼