Strict – Confronto debole o forte
<!DOCTYPE html> <!-- Copyright 2021 Alessandro Barazzuol https://www.alessandrobarazzuol.com HTML_JS . --> <html> <head> <title>Titolo</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> /*Confronto Stretto e confronto debole */ /*confronto stretto detto strike: confronta se due tipi sono * uguali e se sono anche i valori*/ /*il confronto debole TENDE ad essere convertito con cast implicito dal js per cui non sempre è affidabile*/ var S="CONFRONTO DEBOLE"+"<br>"; window.onload=function() { S+="null==undefined" + "-->"+ (null==undefined)+ "<br>"+ "null==0" + "-->"+ (null==0)+"<br>" + "null==' '"+"-->" + (null==' ') +"<br>"+"0=='0'"+"-->"+ (0=='0')+"<br>" +"0==null"+ "-->"+ (0==null)+"<br>"+"0=='00'"+"-->"+ (0=='00')+"<br>"+ "CONFRONTO FORTE o STRICT"+"<br>"+ "null===undefined" + "-->"+ (null===undefined)+ "<br>"+ "null===0" + "-->"+ (null===0)+"<br>" + "null===' '"+"-->" + (null===' ') +"<br>"+"0==='0'"+"-->"+ (0==='0')+"<br>" +"0===null"+ "-->"+ (0===null)+"<br>"+"0==='00'"+"-->"+ (0==='00')+"<br>" +"NON USARE MAI IL NaN PERCHè : "+ "NaN != Nan "+ "-->"+(NaN!=NaN)+".....non si è mai capito il perchè<br>"; document.getElementById("c").innerHTML=S; } </script> </head> <body> <p id="c"> </p> <div></div> </body> </html>