remove a property from a JavaScript object?
delete myObject.regex;
// or,
delete myObject['regex'];
// or,
var prop = "regex";
delete myObject[prop];
html,html5,css3,php,css,javascript,html tags, php,svg,jquery solutions
delete myObject.regex;
// or,
delete myObject['regex'];
// or,
var prop = "regex";
delete myObject[prop];
// Non-strict code...
(function(){
"use strict";
// Define your library strictly...
})();
// Non-strict code...
var string = "foo",
substring = "oo";
string.includes(substring)
includes doesn’t have IE support, though. In an ES5 or older environment, String.prototype.indexOf, which returns −1 when it doesn’t find the substring, can be used instead:
var string = "foo",
substring = "oo";
string.indexOf(substring) !== -1
var array = [2, 5, 9];
console.log(array)
var index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
// array = [2, 9]
console.log(array);
function sayHello(name) {
var text = 'Hello ' + name;
var say = function() { console.log(text); }
say();
}
sayHello('lisa');
$('#myForm input').on('change', function() {
alert($('input[name=radioName]:checked', '#myForm').val());
});
background-color:rgba(255,0,0,0.5);
remove a property from a JavaScript object? delete myObject.regex; // or, delete myObject['regex']; // or, var prop = ...