JavaScript Basics
JavaScript Basics
Variables
Variables[1] are data stored as a value in a named space. Variables can be used as a mathematical constant,[2] to use in math commands to generate a user output,[3] such as e,[4] which has a value of 2.718281828459045. To declare a new constant, type the keyword "const",[5] and add the assignment declaration. Add the value to declare the constant. Note that constants cannot be changed afterward, which should be self-explanatory. Normal variables work the same way, and can be changed accordingly depending on user input. Variables can also hold strings,[6] which is useful for input such as authorization[7] or for a search engine.[8] Variables can also identify as undefined[9] or null.[10]
Functions
Functions[11] are a keyword used in object-oriented programming. These are used to run code multiple times, for example, a login button. They can setup the procedure and insert it inside of a function named loginProcedure. Using the Document Object Model, they can have the function execute when an HTML element is clicked.
Event Keywords
Events is a trigger usually initiated by user input,[3] which allows certain blocks of code to execute. Here's a complete list.
WebSockets and User Connections
User connections include social networking,[12] messaging between users,[13] or playing an online game.[14] WebSocket[15] is a protocol used for seamless and fast communication listening on a port.[16] Encoded messages are sent over this line, usually in a JSON format.[17] WebSocket is supported by Google Chrome, Firefox, Safari, Microsoft Edge, Internet Explorer, and Opera. This server can be utilized with a variable. Declare a variable and set the value to "new WebSocket()". Inside of the parentheses put the URL (Uniform Resource Locator) of your WebSocket connection. Create custom functions for this to create a chat application or another idea.
Recap
View the references for more info on this topic. Event keywords, WebSockets, Functions, and Variables were all listed in this page.
// Variables
var variable = 1;
const constant = 2;
// Better to use let keyword
let username = user;
// Functions
function myFunction() {
console.log("Hello World!")
}
// Execute this function
myFunction()
// WebSockets
let socket = new WebSocket("server-url")
/* Add your custom WebSocket
functionality here! */
View the references for more info.
References
- ↑ "Variable (computer science)", Wikipedia, 2022-08-19, retrieved 2022-08-29
- ↑ "Constant (mathematics)", Wikipedia, 2022-06-02, retrieved 2022-08-29
- ↑ 3.0 3.1 "Input/output", Wikipedia, 2022-08-28, retrieved 2022-08-29
- ↑ "e (mathematical constant)", Wikipedia, 2022-08-26, retrieved 2022-08-29
- ↑ "const (computer programming)", Wikipedia, 2022-08-20, retrieved 2022-08-29
- ↑ "String (computer science)", Wikipedia, 2022-08-01, retrieved 2022-08-29
- ↑ "Authorization", Wikipedia, 2022-08-18, retrieved 2022-08-29
- ↑ "Search engine", Wikipedia, 2022-08-28, retrieved 2022-08-29
- ↑ "Undefined value", Wikipedia, 2021-12-09, retrieved 2022-08-29
- ↑ "Null character", Wikipedia, 2022-08-10, retrieved 2022-08-29
- ↑ "Function object", Wikipedia, 2022-04-22, retrieved 2022-08-29
- ↑ "Social networking service", Wikipedia, 2022-08-22, retrieved 2022-08-29
- ↑ "Message", Wikipedia, 2022-07-26, retrieved 2022-08-29
- ↑ "Multiplayer video game", Wikipedia, 2022-08-12, retrieved 2022-08-29
- ↑ "WebSocket", Wikipedia, 2022-08-06, retrieved 2022-08-29
- ↑ "Port (computer networking)", Wikipedia, 2022-08-04, retrieved 2022-08-29
- ↑ "JSON", Wikipedia, 2022-08-25, retrieved 2022-08-29
This article "JavaScript Basics" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:JavaScript Basics. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.
