JS objects Miscellany

delete keywords to delete properties from an object deletes both the value of the property and the property itself, after the removal is complete, the properties before being added back can not be used,

delete operator is designed for object attributes. It does not affect the function or variable.

delete operator should not be used predefined JavaScript object properties. Doing so will make the application to crash.

arguments object

JavaScript function has a built-in object named arguments object. It contains an array of parameters used in the function call. We can easily use it for some actions, such as to obtain the maximum or minimum value.

 1 function findMax() {
 2   var i;
 3   var max = -Infinity;
 4   for(i = 0; i < arguments.length; i++) {
 5     if (arguments[i] > max) {
 6       max = arguments[i];
 7     }
 8   }
 9   return max;
10 } 
11 document.getElementById("demo").innerHTML = findMax(4, 5, 6);

 

Guess you like

Origin www.cnblogs.com/chen2608/p/11100183.html