_04_js_operate.html 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. </head>
  7. <body>
  8. </body>
  9. <script>
  10. /**
  11. * == 和 === 区别
  12. * == 只会比较两个值是否相同
  13. * === 不仅会比较值是否相同还会比较类型
  14. */
  15. var a = 10;
  16. var b = "10";
  17. console.log(a==b) // true 相当于java 当中equlas 比较
  18. console.log(a===b) // false 相当于java 当中==
  19. if (0){
  20. console.log("条件成立")
  21. }else{
  22. console.log("条件不成立")
  23. }
  24. if (null){
  25. console.log("条件成立")
  26. }else{
  27. console.log("条件不成立")
  28. }
  29. if (NaN){
  30. console.log("条件成立")
  31. }else{
  32. console.log("条件不成立")
  33. }
  34. if (""){
  35. console.log("条件成立")
  36. }else{
  37. console.log("条件不成立")
  38. }
  39. if (undefined){
  40. console.log("条件成立")
  41. }else{
  42. console.log("条件不成立")
  43. }
  44. var c = "111";
  45. var d = "abc11"
  46. console.log(typeof c)
  47. console.log(typeof parseInt(c))
  48. // Nan
  49. // console.log(parseInt(d))
  50. // console.log(typeof parseInt(d));
  51. </script>
  52. </html>