property

/Tag: property

How To Loop Through An Object In JavaScript

2019-07-22T15:04:24-04:00

In JavaScript there's a way to access all the items in an object called the for in loop.  It allows you to iterate (or loop) through all the key value pairs in an object.  For example, if we had this object: var jsobj = { company: "SkillForge", course: "JavaScript", isFun: "Yes" } We would be able to get the keys and the values out of it using the for in loop.  To pull the keys out we could do this: for(x in jsobj){ document.write(x + "<br>"); } In this loop, x is a variable that will be holding all of the [...]

How To Loop Through An Object In JavaScript2019-07-22T15:04:24-04:00

innerHTML vs textContent – The Difference Between These JavaScript Properties

2018-11-12T11:19:38-04:00

innerHTML vs. textContent, what is the difference between these JavaScript properties and which one should you use?  They do the same thing, right?  No, they actually do not.  The difference between the .innerHTML and .textContent properties is all about the HTML my friends!  textContent renders text and only text, and innerHTML renders text with any HTML applied to it.  To illustrate, here's a quick example you can try in your chosen text editor (just copy and paste it in if you want): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>innerHTML vs textContent</title> </head> <body> <h2>textContent:</h2> <!--Div that will hold the textContent text--> [...]

innerHTML vs textContent – The Difference Between These JavaScript Properties2018-11-12T11:19:38-04:00