Javascript if statement

Created By: chatGPT

JavaScript provides the if statement as a basic control structure used to execute a block of code based on a specified condition. If the condition evaluates to true, the code inside the if block will run. If it's false, the code will be skipped.
if (condition) {
    // Code to execute if condition is true
}
You can also use the else statement to define a block of code that runs when the condition is false. This is useful for handling different scenarios based on the condition's evaluation.
if (condition) {
    // Code to execute if condition is true
} else {
    // Code to execute if condition is false
}
In addition to if and else, JavaScript allows the use of else if to evaluate multiple conditions sequentially. This enables you to test for additional criteria if the first condition fails.
if (condition1) {
    // Code for condition1
} else if (condition2) {
    // Code for condition2
} else {
    // Code if none of the conditions are met
}
When writing conditions, you can use comparison operators like ===, !==, <, >, <=, and >= to form logical expressions.
let num = 10;
if (num > 5) {
    console.log('Number is greater than 5');
} else {
    console.log('Number is 5 or less');
}
It’s also common to use logical operators like && (and) and || (or) to create more complex conditions. This allows for multiple criteria to be evaluated in one statement.
if (condition1 && condition2) {
    // Code if both conditions are true
}

if (condition1 || condition2) {
    // Code if at least one condition is true
}
Introduction And SetupVariablesData TypesMethodsControl FlowFunctionsOperatorsData StructuresCommentsSyntaxEvent HandlingError HandlingPrimitive Data TypesReference Data TypesConstLetVarStringNumberBooleanNullUndefinedSymbolObjectArrayTemplate LiteralsArrow FunctionsRegular FunctionsCallApplyBindAsync FunctionsPromisesCallback FunctionsIf StatementElse StatementSwitch StatementFor LoopWhile LoopDo While LoopFor EachBreak StatementContinue StatementTry CatchThrowFinallyScopeClosureThis KeywordPrototypesInheritanceConstructor FunctionsClass SyntaxStatic MethodsGettersSettersSpread OperatorRest OperatorDestructuring AssignmentMap MethodFilter MethodReduce MethodEvent ListenersDom ManipulationInnerHTMLQuerySelectorAddEventListenerPreventDefaultStopPropagationTimeoutsIntervalsJsonLocal StorageSession StorageRegexMath ObjectDate ObjectString MethodsArray MethodsObject MethodsDeep CloningShallow CloningCallback HellPromise ChainingAsync AwaitMap Vs ForEachFilter Vs ReduceNullish Coalescing OperatorOptional ChainingTypeof OperatorInstanceof OperatorStrict EqualityLoose Equality