Tricky Parts of JavaScript [Part 4]

in #javascript6 years ago

Welcome to the 4th part of JavaScript and I hope you are doing well and learning from my blogs. In this part we will be looking at the most basic stuff that is crucial for a complete understanding of web development. These posts are to teach you the basic functioning of JavaScript so that you can tackle any complicated problem in future. Here we begin...



Q1. What is data-* attribute?

Ans : These data-* attributes helps us to store extra data in the DOM. The best part is we can write the private data that is going to be embedded in the HTML. Further, the data we have embedded can be accessed through JavaScript and other JS libs e.g Knockout


<div data-name="funnyman" data-life="70"> </div>


Q2. Will the following code do any requests/response stuff?


<img src="/terminal.png" />

<style>
 img {visibility: hidden;}
</style>


Ans: The answer is Yes, the above code is going to do a GET request while page load. No matter what is it's visibility, it is going to download the image to be presented to the user and will be stored in the DOM temporarily.


Q3. What is an Optional Closing Tag?

Ans: These are the special tags that we don't need to close. Browsers are smart enough to distinguish those tags and ultimately puts the closing part of the tag on its own. One thing to notice here is that it might not be true in every case. E.g ReactJS which uses JSX as template engine and it would not care about the optional closing tags, you would have to put it. That's why your code should be consistent and follow a certain coding pattern.

e.g : li, p ,td and the list goes on. You can look it up the complete list.


More CONTENT to COME...STAY TUNED!

@funnyman


Sort:  

GREAT content man. You deserve it.

Thanks for this amazing tutorial. Very helpful.

Great job man. Very informative.

Nicely done.

Very well presented. Love it.

I loved this <3 Being a JS coder :P

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64029.44
ETH 3157.04
USDT 1.00
SBD 4.02