Skip to content Skip to sidebar Skip to footer

Javascript Delete Method?

In this code snippet from AdvancED DOM Scripting: The call to delete(classes[i]); is this an array or object method? I'm unable to Google an answer. /** * remove a class from an e

Solution 1:

The Mozilla Reference Docs says the following regarding the delete operator:

The delete operator deletes an object, an object's property, or an element at a specified index in an array.

For more information, see the following article:

http://perfectionkills.com/understanding-delete/


Solution 2:

delete will set the value of the specified member (variable/array/object) to undefined

array/object example...

since classes[i] is actually referencing the i index of the array. It will set that specific index position to undefined, reserving the position in the array...


Solution 3:

I think you can use simply $('p').removeClass('myClass yourClass') with jquery and put together a function to do so for any element


Post a Comment for "Javascript Delete Method?"