What is function and why do we use it?
- Local and Global variables in JavaScript.
A small thread🧵👇
- A JavaScript function is a block of code designed to perform a particular task. It allows us to write more maintainable code. Define the code once, and use it many times. You don’t need to write the same code over and over again.
- It is defined with the function keyword, followed by a name and parentheses (). The code to be executed by the function is placed inside curly brackets: {}
- A JavaScript function is executed when "something" invokes it (calls it).
What are Parameters and Arguments?
Parameters: These are the list of variables used in the parentheses( ) while declaring a function.
Arguments: These are the list of values we pass into the function when we make a function call.
Local and Global variables:
Local Variable: Variables that are declared within or inside a function block are known as Local variables.
- These variables can only be accessed within the function in which they are declared.
- Scope is limited.
Global Variable: Variables that are declared outside of all the functions or blocks and can be accessed globally in a program.
- It can be accessed by any function present in the program.
- They are useful if all the functions are accessing the same data.
That's all for the thread if you find it useful retweet the first one.
Happy Learning.🌸
• • •
Missing some Tweet in this thread? You can try to
force a refresh
1- Figure: The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, etc.
- The <figcaption> element is used to add a caption for the <figure> element.
2- Details: The <details> tag is often used to create an interactive widget that the user can open and close. By default, the widget is closed. When open, it expands and displays the content within.
- The <summary> tag defines a visible heading for the <details> element.
- Send Mail: While using <a> tag as an email tag, you will use mailto: email address along with href attribute.
- Dropdown Input: The <select> element is used to create a drop-down list. It is most often used in a form, to collect user input.
- The <option> tags inside the <select> element define the available options in the drop-down list.
1- Spellcheck: The spellcheck is used to check the spelling and grammar of Html elements such as input.
2- Translate: The translate attribute is used to tell the browser whether the content is to be translated or not.
It can be translated into any language.