xxxxxxxxxx
document.getElementById("myDIV").className = "mystyle";
xxxxxxxxxx
class Language {}
const l1 = new Language();
console.log(l1.constructor.name);
xxxxxxxxxx
class Language {
getClassName() {
return this.constructor.name;
}
}
const l1 = new Language ();
const objClassName = l1.getClassName();
console.log(objClassName);
xxxxxxxxxx
var spans = document.getElementsByTagName("span");
for (var i = 0; i < spans.length; i++) {
if (spans[i].className == 'xyz') {
spans[i].style.backgroundColor = '#000';
}
}
xxxxxxxxxx
const Season = [
{
month:'January',
season: 'Winter',
},
{
month:'March',
season: 'Spring',
},
{
month:'June',
season: 'Summer',
},
{
month:'August',
season: 'Autumn',
},
]
const index = Season.findIndex( (loopVariable) => loopVariable.month === 'March');
console.log("The index of March Month is",index)
xxxxxxxxxx
const Season = [
{
month:'January',
season: 'Winter',
},
{
month:'March',
season: 'Spring',
},
{
month:'June',
season: 'Summer',
},
{
month:'August',
season: 'Autumn',
},
]
const index = Season.map( (loopVariable) => loopVariable.month).indexOf
("March"));
console.log("The index of March Month is",index)
xxxxxxxxxx
var what = function(obj) {
return obj.toString().match(/ (\w+)/)[1];
};