About 1,290 results
Open links in new tab
  1. setting a javascript variable with an if statement -- should the 'var ...

    Initialize your variables first, then compare using if statement and assign new values where necessary . var a = "red"; var b; if(a=="red"){ b="hot"; } else{ b="cold"; }

  2. JavaScript if/else Statement - W3Schools

    The if/else statement is a part of JavaScript's "Conditional" Statements, which are used to perform different actions based on different conditions. In JavaScript we have the following conditional statements: Use if to specify a block of code to be executed, if a specified condition is true

  3. var - JavaScript | MDN - MDN Web Docs

    Mar 13, 2025 · The var statement declares function-scoped or globally-scoped variables, optionally initializing each to a value.

  4. JavaScript Var Statement - GeeksforGeeks

    Feb 10, 2025 · The var keyword is used to declare variables in JavaScript. It has been part of the language since its inception. When a variable is declared using var, it is function-scoped or globally-scoped, depending on where it is declared. Syntax. var variable = value;

  5. Best Way for Conditional Variable Assignment - Stack Overflow

    Method 1: If the condition evaluates to true, the value on the left side of the column would be assigned to the variable. If the condition evaluates to false the condition on the right will be assigned to the variable. You can also nest many conditions into one statement.

  6. JavaScript Conditionals: The Basics with Examples | JavaScript

    Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run. There are multiple different types of conditionals in JavaScript including: “If” statements: where if a condition is true it is used to specify execution for a block of code.

  7. JavaScript if else if - JavaScript Tutorial

    Summary: In this tutorial, you will learn how to use the JavaScript if...else...if statement to check multiple conditions and execute the corresponding block if a condition is true. The if an if…else statements accepts a single condition and executes the if …

  8. JavaScript var Statement - W3Schools

    Declare many variables in one statement. Start the statement with var and separate the variables by comma:

  9. The old "var" - The Modern JavaScript Tutorial

    Nov 13, 2022 · With var, we can redeclare a variable any number of times. If we use var with an already-declared variable, it’s just ignored: var declarations are processed when the function starts (or script starts for globals).

  10. JavaScript if...else Statement (with Examples) - Programiz

    The JavaScript if…else statement is used to execute/skip a block of code based on a condition. In this tutorial, we will learn about the JavaScript if…else statement with examples.

  11. Some results have been removed
Refresh