Let's redefine the "undefined". Can we do it in JavaScript?

➊ What is "undefined"?

❑ "undefined" is a variable in the global scope. The value of "undefined" is the primitive value "undefined"

❒ When a variable is declared but not assigned any value, value of global variable "undefined" is assigned to it implicitly.
➋ "undefined" is not a reserved keyword

❑ It means you can declare a variable named "undefined".

❒ So, what will happen if you declare a variable called "undefined" and assign some other value to it?

Let's explore.
➌ Redefining "undefined": Part 1

❑ We already said, "undefined" is a variable in the global scope.

❒ So, you can't declare another variable named "undefined" in the global scope. Image
➍ Redefining "undefined": Part 2

❑ You can declare a variable named "undefined" in a function or, block. That's allowed.

❒ And as you might have suspected, we lost access to "undefined" in global scope.

❑ You can access it using "window.undefined". Image
💭 Final Words

❑ "undefined" is not a reserved keyword. Hence you can redefine it, but not in global scope.

❒ Though it's allowed, we should avoid doing it. It will pollute the code. Consider this as a BAD PRACTICE.
End of 🧵

Are you learning JavaScript? Or, a strong JavaScript enthusiast? I have been sharing interesting and useful threads and infographics on JavaScript. Check my "Moments" section for more.

To never miss any future contents, Follow Me ✅

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Swapna Kumar Panda 

Swapna Kumar Panda  Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @swapnakpanda

Mar 13
25 super useful methods in JavaScript

💭 Why this thread?

❑ If you have just started learning JavaScript, you might have felt exhausted by seeing so many methods.

❒ If you are simply going through those methods without knowing their use cases, it's going to be tough for you later.

❑ Let's learn use cases.
📋 Table of Contents

❑ Array.prototype's

➊ forEach()
➋ map()
➌ reduce()
➍ every()
➎ filter()
➏ find()
➐ slice()
➑ splice()
➒ push()
➓ pop()
➊➊ shift()
➊➋ unshift()
➊➌ indexOf()
➊➍ findIndex()
➊➎ sort()
Read 25 tweets
Mar 12
💎 JavaScript Cheat Sheet : Math Object

Find Complete Reference of
❍ 8 Constants
❍ 35 Functions

✧ Link to High Resolution image in the next tweet JavaScript Math Object  1. ...
🏙 High Resolution Image

⬒ If you liked this one, give a ⭐️ to this GitHub repo to support my work.

⬓ Direct Link:
github.com/swapnakpanda/I…
🚥 Disclaimer

⬔ I have compiled these information with all sincerity. But in case you find any omissions or, wrong representations, 💬 me.

⬕ Share your feedbacks if you see any area of improvement for me. Feedbacks are highly appreciated.
Read 4 tweets
Mar 10
🟦 All inline & block-level elements in HTML / CSS

Check inside the 🧵 for

✧ Interesting details about inline & block-level
✧ Link to high resolution image

HTML elements can be categorized as either "block-level
📋 Table of Contents

➊ Introduction
➋ inline-level
➌ block-level
➍ Changing Element Level
➎ List of inline-level elements
➏ List of block-level elements
➐ Link to High Resolution Image
🚥 Disclaimer

❑ I have compiled these information with all sincerity. But in case you find any omissions or, wrong representations, 💬 me.

❒ If you have any suggestions or, feedbacks, share those with me. I am eager to hear from you.
Read 18 tweets
Mar 9
🏙 Should we use Semantic HTML?

✘ <div> ➜ <header> ✓
✘ <div> ➜ <nav> ✓
✘ <div> ➜ <section> ✓
✘ <div> ➜ <article> ✓
✘ <div> ➜ <aside> ✓
✘ <div> ➜ <main> ✓
✘ <div> ➜ <summary> ✓
✘ <div> ➜ <footer> ✓

We will discuss about

➊ What is Semantic HTML?
➋ Examples of Semantic Elements
➌ Benefits of using Semantic HTML
➌.➀ Improve site's SEO positioning
➌.➁ Help your site more accessible
➌.➂ Closer to natural language, easier to maintain
➍ Should we not use "div"?
➊ What is Semantic HTML?

❏ Semantic HTML adds essential meaning to the web page rather than just presentation.

❐ This lets web browsers, search engines, screen readers, RSS readers, and ultimately users understand it in a better way.
Read 14 tweets
Mar 8
Memorise JavaScript Array Methods in 11 Steps

📋 TOC

➊ Static Methods
➋ Accepts -ve Index
➌ Returns Boolean
➍ Returns Index
➎ Returns new Array
➏ Modifies Existing Array
➐ Iterates through entire Array
➑ Iterates Partially
➒ Checks Elements "as it is"
➓ Checks Elements custom way
➊➊ Accepts a callback
➊ Static Methods

❍ of()
❍ from()
❍ isArray()
Read 15 tweets
Mar 7
10 HTML Tags and Attributes for SEO

📋 Table of Contents

We will discuss about

➊ <title>
➋ <meta name = "description" >
➌ <h1> to <h6>
➍ <img alt="...">
➎ <a rel="nofollow">
➏ <meta name = "robots" >
➐ <link rel = "canonical" >
➑ <meta name = "viewport" >
➒ Open Graph Tags
➓ Twitter Card Tags
🔍 Introduction

❑ When search engines crawl a website, it goes through all the HTML documents.

❒ Various HTML tags and, attributes help search engine to determine what your content is about and, how to categorise it.

❑ So all these may affect how your website performs.
Read 16 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(