Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js object clear

// for enumerable and non-enumerable of an object with proto chain
var props = Object.getOwnPropertyNames(obj);
for (var i = 0; i < props.length; i++) {
  delete obj[props[i]];
}

// for enumerable properties of shallow/plain object
for (var key in obj) {
  // this check can be safely omitted in modern JS engines
  // if (obj.hasOwnProperty(key))
    delete obj[key];
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: map array method create object 
Javascript :: http node 
Javascript :: disable button using jquery 
Javascript :: remove element from array by name javascript 
Javascript :: sum values in array javascript 
Javascript :: how to import svg in react 
Javascript :: vue router guard 
Javascript :: Handle click outside a component in react with hooks 
Javascript :: remove object in array javascript 
Javascript :: frequency of characters in a string in javascript 
Javascript :: reverse string in js 
Javascript :: getFullYear within moment in angular 
Javascript :: javascript split regex new line 
Javascript :: javascript count character in string 
Javascript :: how to update angular core in ionic 
Javascript :: debouncing js 
Javascript :: set background image URL jQuery 
Javascript :: cookie in javascript 
Javascript :: jquery: select select box rpogramatically 
Javascript :: angular loop through key values in map 
Javascript :: filter array of objects with array of objects 
Javascript :: string to array angular 
Javascript :: even or odd in javascript 
Javascript :: how to give height through props 
Javascript :: yaml to json javascript 
Javascript :: how to display image before upload in jhtml 
Javascript :: how to validate email in node js 
Javascript :: v-btn click 
Javascript :: firebase auth api key not valid. please pass a valid api key 
Javascript :: react native image 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =