-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript-guide.html
More file actions
2456 lines (2039 loc) · 93.8 KB
/
javascript-guide.html
File metadata and controls
2456 lines (2039 loc) · 93.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="he" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>מדריך JavaScript מקיף - CopyCode</title>
<link rel="icon" href="images/logo.png" type="image/png">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
background: url('images/background.jpg') center center / cover no-repeat fixed;
min-height: 100vh;
line-height: 1.6;
color: #2c3e50;
position: relative;
}
body::before {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
z-index: 0;
pointer-events: none;
}
.top-header {
position: fixed;
top: 0;
right: 0;
left: 0;
height: 70px;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 2rem;
z-index: 1000;
}
.site-logo {
display: flex;
align-items: center;
gap: 0.75rem;
text-decoration: none;
color: #1a1a1a;
font-size: 1.3rem;
font-weight: 600;
transition: all 0.3s ease;
}
.site-logo:hover {
color: #667eea;
}
.site-logo img {
width: 40px;
height: 40px;
}
.search-btn {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.7rem 1.5rem;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
text-decoration: none;
border-radius: 12px;
font-weight: 600;
transition: all 0.3s ease;
border: none;
cursor: pointer;
}
.search-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}
.search-btn svg {
width: 20px;
height: 20px;
}
.layout {
display: flex;
max-width: 1400px;
margin: 0 auto;
min-height: 100vh;
position: relative;
z-index: 1;
padding-top: 90px;
}
.sidebar {
width: 260px;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
padding: 2rem 1rem;
margin-left: 1.5rem;
position: sticky;
top: 110px;
height: calc(100vh - 130px);
overflow-y: auto;
border-left: 1px solid rgba(255, 255, 255, 0.3);
box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
border-radius: 16px;
scrollbar-width: none;
-ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar {
display: none;
}
.sidebar-title {
font-size: 1.1rem;
color: #2c3e50;
margin-bottom: 1.5rem;
font-weight: 600;
padding-bottom: 0.75rem;
border-bottom: 2px solid #F7DF1E;
}
.nav-menu {
list-style: none;
}
.nav-item {
margin-bottom: 0.25rem;
}
.nav-link {
display: block;
padding: 0.6rem 0.8rem;
color: #5a6c7d;
text-decoration: none;
border-radius: 4px;
transition: all 0.2s ease;
font-size: 0.9rem;
font-weight: 500;
}
.nav-link:hover {
background: #ecf0f1;
color: #2c3e50;
padding-right: 1rem;
}
.nav-link.active {
background: #F7DF1E;
color: #000;
}
.container {
flex: 1;
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
margin: 0 1.5rem 1.5rem 1.5rem;
border-radius: 16px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
overflow: hidden;
}
header {
background: transparent;
color: #1a1a1a;
padding: 2.5rem 2rem;
text-align: center;
border-bottom: 1px solid #e9ecef;
}
h1 {
font-size: 2.2rem;
margin-bottom: 0.5rem;
font-weight: 600;
letter-spacing: -0.5px;
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
}
h1 svg {
width: 48px;
height: 48px;
}
.subtitle {
font-size: 1rem;
opacity: 0.85;
font-weight: 500;
}
.content {
padding: 2.5rem;
}
.section {
margin-bottom: 3rem;
}
.section-title {
font-size: 1.6rem;
color: #2c3e50;
margin-bottom: 1.5rem;
padding-bottom: 0.5rem;
border-bottom: 2px solid #F7DF1E;
font-weight: 600;
}
.command-group {
background: #f8f9fa;
border: 1px solid #e1e8ed;
border-radius: 6px;
padding: 1.5rem;
margin-bottom: 1.5rem;
transition: box-shadow 0.2s ease;
}
.command-group:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.command-title {
font-size: 1.1rem;
color: #2c3e50;
margin-bottom: 1rem;
font-weight: 600;
}
.command-wrapper {
position: relative;
margin: 0.8rem 0;
}
.command {
background: #1e1e1e;
color: #d4d4d4;
padding: 0.9rem 3rem 0.9rem 1rem;
border-radius: 4px;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 0.9rem;
direction: ltr;
text-align: left;
border: 1px solid #F7DF1E;
position: relative;
overflow-x: auto;
white-space: pre-wrap;
line-height: 1.5;
}
.copy-btn {
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
background: transparent;
color: #7f8c8d;
border: 1px solid #bdc3c7;
padding: 0.4rem;
border-radius: 3px;
cursor: pointer;
font-size: 0.75rem;
transition: all 0.2s ease;
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
font-family: monospace;
}
.copy-btn::before {
content: '⧉';
font-size: 1rem;
}
.copy-btn:hover {
background: #ecf0f1;
color: #2c3e50;
border-color: #95a5a6;
}
.copy-btn:active {
transform: translateY(-50%) scale(0.95);
}
.copy-btn.copied {
background: #d5f4e6;
color: #27ae60;
border-color: #27ae60;
}
.copy-btn.copied::before {
content: '✓';
}
.description {
color: #5a6c7d;
margin-bottom: 0.5rem;
margin-top: 1rem;
font-weight: 500;
font-size: 0.95rem;
}
.explanation {
background: #fff9e6;
border-right: 3px solid #F7DF1E;
padding: 0.75rem;
margin: 0.5rem 0;
border-radius: 4px;
color: #34495e;
font-size: 0.88rem;
line-height: 1.5;
}
.note {
background: #fff3cd;
border-right: 3px solid #F7DF1E;
padding: 1rem;
border-radius: 4px;
margin: 1rem 0;
}
.note-title {
font-weight: 600;
color: #856404;
margin-bottom: 0.5rem;
}
footer {
background: linear-gradient(135deg, #F7DF1E 0%, #F0DB4F 100%);
color: #000;
text-align: center;
padding: 1.5rem;
font-size: 0.85rem;
border-top: 3px solid #323330;
}
@media (max-width: 1024px) {
.layout {
flex-direction: column;
}
.sidebar {
width: 100%;
height: auto;
position: relative;
border-left: none;
border-bottom: 2px solid #F7DF1E;
}
.container {
margin: 0 1rem 1rem 1rem;
}
}
@media (max-width: 768px) {
h1 {
font-size: 1.8rem;
}
.section-title {
font-size: 1.4rem;
}
.command {
font-size: 0.82rem;
padding-left: 0.8rem;
}
.content {
padding: 1.5rem;
}
}
.scroll-top {
position: fixed;
bottom: 2rem;
left: 2rem;
background: #F7DF1E;
color: #000;
width: 48px;
height: 48px;
border-radius: 4px;
border: none;
cursor: pointer;
font-size: 1.3rem;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
transition: all 0.2s ease;
opacity: 0;
visibility: hidden;
}
.scroll-top.visible {
opacity: 1;
visibility: visible;
}
.scroll-top:hover {
background: #F0DB4F;
transform: translateY(-3px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<div class="top-header">
<a href="index.html" class="site-logo">
<img src="images/logo.png" alt="לוגו האתר">
CopyCode
</a>
<a href="search.html" class="search-btn">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>חיפוש</span>
</a>
</div>
<div class="layout">
<nav class="sidebar">
<div class="sidebar-title">תוכן עניינים</div>
<ul class="nav-menu">
<li class="nav-item"><a href="#basics" class="nav-link">יסודות JavaScript</a></li>
<li class="nav-item"><a href="#variables" class="nav-link">משתנים</a></li>
<li class="nav-item"><a href="#datatypes" class="nav-link">טיפוסי נתונים</a></li>
<li class="nav-item"><a href="#operators" class="nav-link">אופרטורים</a></li>
<li class="nav-item"><a href="#strings" class="nav-link">מחרוזות</a></li>
<li class="nav-item"><a href="#arrays" class="nav-link">מערכים</a></li>
<li class="nav-item"><a href="#objects" class="nav-link">אובייקטים</a></li>
<li class="nav-item"><a href="#functions" class="nav-link">פונקציות</a></li>
<li class="nav-item"><a href="#control" class="nav-link">בקרת זרימה</a></li>
<li class="nav-item"><a href="#loops" class="nav-link">לולאות</a></li>
<li class="nav-item"><a href="#dom" class="nav-link">DOM Manipulation</a></li>
<li class="nav-item"><a href="#events" class="nav-link">Events</a></li>
<li class="nav-item"><a href="#async" class="nav-link">Async/Await</a></li>
<li class="nav-item"><a href="#es6" class="nav-link">ES6+ Features</a></li>
<li class="nav-item"><a href="#modules" class="nav-link">Modules</a></li>
<li class="nav-item"><a href="#json" class="nav-link">JSON ו-APIs</a></li>
</ul>
</nav>
<div class="container">
<header>
<h1>
<svg viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
<path fill="#F7DF1E" d="M0 0h256v256H0V0z"/>
<path d="M67.312 213.932l19.59-11.856c3.78 6.701 7.218 12.371 15.465 12.371 7.905 0 12.89-3.092 12.89-15.12v-81.798h24.057v82.138c0 24.917-14.606 36.259-35.916 36.259-19.245 0-30.416-9.967-36.087-21.996M152.381 211.354l19.588-11.341c5.157 8.421 11.859 14.607 23.715 14.607 9.969 0 16.325-4.984 16.325-11.858 0-8.248-6.53-11.17-17.528-15.98l-6.013-2.58c-17.357-7.387-28.87-16.667-28.87-36.257 0-18.044 13.747-31.792 35.228-31.792 15.294 0 26.292 5.328 34.196 19.247l-18.732 12.03c-4.125-7.389-8.591-10.31-15.465-10.31-7.046 0-11.514 4.468-11.514 10.31 0 7.217 4.468 10.14 14.778 14.608l6.014 2.577c20.45 8.765 31.963 17.7 31.963 37.804 0 21.654-17.012 33.51-39.867 33.51-22.339 0-36.774-10.654-43.819-24.574"/>
</svg>
מדריך JavaScript מקיף
</h1>
<p class="subtitle">מיסודות ועד מתקדם - השפה של האינטרנט</p>
</header>
<div class="content">
<!-- יסודות JavaScript -->
<section id="basics" class="section">
<h2 class="section-title">יסודות JavaScript</h2>
<div class="note">
<div class="note-title">💡 מה זה JavaScript?</div>
<strong>JavaScript</strong> היא שפת התכנות של האינטרנט! כל אתר אינטראקטיבי משתמש בה.<br>
<strong>לא להתבלבל:</strong> JavaScript ≠ Java (שפות שונות לחלוטין!)<br>
<strong>איפה רץ?</strong> בדפדפן (Chrome, Firefox) ובשרת (Node.js)<br>
<strong>למה ללמוד?</strong> חיונית לפיתוח web, אפליקציות מובייל (React Native), ואפילו שרתים!<br>
<strong>טיפ:</strong> אפשר לפתוח את ה-Console בדפדפן (F12) ולהתנסות בקוד מיד!
</div>
<div class="command-group">
<h3 class="command-title">הדפסה ל-Console</h3>
<p class="description">הדפסה בסיסית:</p>
<div class="command-wrapper">
<div class="command">console.log("Hello, World!");
console.log("JavaScript", "is", "awesome!");</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">סוגי הדפסה שונים:</p>
<div class="command-wrapper">
<div class="command">console.log("רגיל"); // הדפסה רגילה
console.warn("אזהרה"); // אזהרה (צהוב)
console.error("שגיאה"); // שגיאה (אדום)
console.info("מידע"); // מידע
console.table([1, 2, 3]); // טבלה</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">הערות</h3>
<p class="description">הערות בקוד:</p>
<div class="command-wrapper">
<div class="command">// הערה בשורה אחת
/* הערה
מרובת
שורות */
/**
* הערת תיעוד (JSDoc)
* @param {string} name - שם המשתמש
*/</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">הוספת JavaScript לדף HTML</h3>
<p class="description">בתוך ה-HTML:</p>
<div class="command-wrapper">
<div class="command"><script>
console.log("Hello!");
</script></div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">קובץ חיצוני:</p>
<div class="command-wrapper">
<div class="command"><script src="script.js"></script></div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<div class="explanation">מומלץ לשים את ה-script בסוף ה-body או להשתמש ב-defer</div>
</div>
</section>
<!-- משתנים -->
<section id="variables" class="section">
<h2 class="section-title">משתנים (Variables)</h2>
<div class="note">
<div class="note-title">💡 מה זה משתנה?</div>
<strong>משתנה</strong> - קופסה שמחזיקה מידע. אפשר לשנות את התוכן שלה.<br>
<strong>3 דרכים להגדיר:</strong><br>
• <code>let</code> - המודרני והמומלץ (ניתן לשינוי)<br>
• <code>const</code> - קבוע (לא ניתן לשינוי)<br>
• <code>var</code> - הישן (לא מומלץ להשתמש)<br>
<strong>כלל אצבע:</strong> תמיד השתמשו ב-const, אלא אם צריך לשנות את הערך - אז let
</div>
<div class="command-group">
<h3 class="command-title">הגדרת משתנים</h3>
<p class="description">let - משתנה שניתן לשינוי:</p>
<div class="command-wrapper">
<div class="command">let name = "Alice";
let age = 25;
let isStudent = true;
// שינוי ערך
age = 26;
name = "Bob";</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">const - קבוע:</p>
<div class="command-wrapper">
<div class="command">const PI = 3.14159;
const MAX_USERS = 100;
const API_KEY = "abc123";
// PI = 3.14; // ❌ שגיאה! לא ניתן לשינוי</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">הגדרה מרובה:</p>
<div class="command-wrapper">
<div class="command">let x = 5, y = 10, z = 15;
const a = 1, b = 2;</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">כללי שמות משתנים</h3>
<div class="explanation">
<strong>✅ חוקי:</strong><br>
• מתחיל באות, $ או _<br>
• יכול להכיל אותיות, מספרים, $ ו-_<br>
• רגיש לאותיות גדולות/קטנות (name ≠ Name)<br>
<br>
<strong>❌ לא חוקי:</strong><br>
• מתחיל במספר (1name)<br>
• מכיל רווחים (my name)<br>
• מילות שמורות (let, const, if)
</div>
<p class="description">דוגמאות:</p>
<div class="command-wrapper">
<div class="command">// ✅ טוב
let userName = "Alice";
let user_age = 25;
let $price = 100;
let _temp = 0;
// ❌ רע
// let 1user = "Bob";
// let user-name = "Alice";
// let let = 5;</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
</section>
<!-- טיפוסי נתונים -->
<section id="datatypes" class="section">
<h2 class="section-title">טיפוסי נתונים (Data Types)</h2>
<div class="note">
<div class="note-title">💡 טיפוסי נתונים ב-JavaScript</div>
<strong>JavaScript היא "dynamically typed"</strong> - לא צריך להגדיר טיפוס, הוא משתנה אוטומטית!<br>
<strong>7 טיפוסים פרימיטיביים:</strong><br>
1. <code>Number</code> - מספרים (5, 3.14, -10)<br>
2. <code>String</code> - טקסט ("Hello")<br>
3. <code>Boolean</code> - true/false<br>
4. <code>Undefined</code> - לא הוגדר<br>
5. <code>Null</code> - ריק במכוון<br>
6. <code>Symbol</code> - ייחודי<br>
7. <code>BigInt</code> - מספרים ענקיים<br>
<strong>+ Object</strong> - מבנה נתונים מורכב
</div>
<div class="command-group">
<h3 class="command-title">Number - מספרים</h3>
<p class="description">מספרים שלמים ועשרוניים:</p>
<div class="command-wrapper">
<div class="command">let integer = 42;
let float = 3.14;
let negative = -10;
let scientific = 2.5e6; // 2,500,000
// מספרים מיוחדים
let infinity = Infinity;
let notANumber = NaN; // Not a Number</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">פעולות מתמטיות:</p>
<div class="command-wrapper">
<div class="command">let sum = 5 + 3; // 8
let diff = 10 - 4; // 6
let product = 4 * 5; // 20
let quotient = 20 / 4; // 5
let remainder = 10 % 3; // 1 (שארית)
let power = 2 ** 3; // 8 (חזקה)</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">String - מחרוזות</h3>
<p class="description">יצירת מחרוזות:</p>
<div class="command-wrapper">
<div class="command">let single = 'Hello';
let double = "World";
let backtick = `Hello World`; // Template literal
// חיבור מחרוזות
let greeting = "Hello" + " " + "World";
let name = "Alice";
let message = `Hello, ${name}!`; // Template literal</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">Boolean - ערכי אמת</h3>
<p class="description">true ו-false:</p>
<div class="command-wrapper">
<div class="command">let isActive = true;
let isLoggedIn = false;
// השוואות מחזירות Boolean
let isEqual = 5 === 5; // true
let isGreater = 10 > 5; // true
let isLess = 3 < 2; // false</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">Undefined ו-Null</h3>
<p class="description">הבדל בין undefined ל-null:</p>
<div class="command-wrapper">
<div class="command">let x; // undefined (לא הוגדר)
let y = undefined; // undefined (במפורש)
let z = null; // null (ריק במכוון)
console.log(x); // undefined
console.log(z); // null</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<div class="explanation">
<strong>undefined</strong> - המשתנה קיים אבל אין לו ערך<br>
<strong>null</strong> - אנחנו מגדירים במפורש שהערך ריק
</div>
</div>
<div class="command-group">
<h3 class="command-title">בדיקת טיפוס</h3>
<p class="description">typeof operator:</p>
<div class="command-wrapper">
<div class="command">console.log(typeof 42); // "number"
console.log(typeof "Hello"); // "string"
console.log(typeof true); // "boolean"
console.log(typeof undefined); // "undefined"
console.log(typeof null); // "object" (באג ידוע!)
console.log(typeof {}); // "object"
console.log(typeof []); // "object"</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">המרות טיפוסים</h3>
<p class="description">המרה למספר:</p>
<div class="command-wrapper">
<div class="command">Number("123"); // 123
parseInt("123"); // 123
parseFloat("3.14"); // 3.14
+"123"; // 123 (קיצור דרך)
Number("abc"); // NaN (לא מספר)</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">המרה למחרוזת:</p>
<div class="command-wrapper">
<div class="command">String(123); // "123"
(123).toString(); // "123"
123 + ""; // "123" (קיצור דרך)</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">המרה ל-Boolean:</p>
<div class="command-wrapper">
<div class="command">Boolean(1); // true
Boolean(0); // false
Boolean("text"); // true
Boolean(""); // false
!!value; // המרה ל-Boolean (קיצור דרך)</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
</section>
<!-- אופרטורים -->
<section id="operators" class="section">
<h2 class="section-title">אופרטורים (Operators)</h2>
<div class="note">
<div class="note-title">💡 מה זה אופרטור?</div>
<strong>אופרטור</strong> - סימן שמבצע פעולה על ערכים.<br>
<strong>חשוב!</strong> JavaScript יש == ו-===. תמיד השתמשו ב-=== (השוואה מדויקת)!<br>
<strong>== vs ===:</strong><br>
• <code>==</code> משווה ערכים (עם המרה אוטומטית)<br>
• <code>===</code> משווה ערכים וטיפוסים (מומלץ!)
</div>
<div class="command-group">
<h3 class="command-title">אופרטורי השוואה</h3>
<p class="description">השוואות:</p>
<div class="command-wrapper">
<div class="command">// שווה (עם המרה)
5 == "5" // true
// שווה מדויק (ללא המרה) - מומלץ!
5 === "5" // false
5 === 5 // true
// לא שווה
5 != "5" // false
5 !== "5" // true
// גדול/קטן
10 > 5 // true
10 < 5 // false
10 >= 10 // true
5 <= 3 // false</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">אופרטורים לוגיים</h3>
<p class="description">AND, OR, NOT:</p>
<div class="command-wrapper">
<div class="command">// AND (&&) - שניהם צריכים להיות true
true && true // true
true && false // false
// OR (||) - לפחות אחד צריך להיות true
true || false // true
false || false // false
// NOT (!) - הפוך
!true // false
!false // true
// דוגמה מעשית
let age = 25;
let hasLicense = true;
let canDrive = age >= 18 && hasLicense; // true</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">אופרטורי השמה</h3>
<p class="description">קיצורי דרך:</p>
<div class="command-wrapper">
<div class="command">let x = 10;
x += 5; // x = x + 5 → 15
x -= 3; // x = x - 3 → 12
x *= 2; // x = x * 2 → 24
x /= 4; // x = x / 4 → 6
x %= 4; // x = x % 4 → 2
x **= 3; // x = x ** 3 → 8
// הגדלה והקטנה
x++; // x = x + 1
x--; // x = x - 1
++x; // הגדלה לפני
--x; // הקטנה לפני</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">אופרטורים מיוחדים</h3>
<p class="description">Ternary operator (תנאי בשורה אחת):</p>
<div class="command-wrapper">
<div class="command">let age = 20;
let status = age >= 18 ? "מבוגר" : "קטין";
// אם age >= 18 אז "מבוגר", אחרת "קטין"
// דוגמה נוספת
let score = 85;
let grade = score >= 90 ? "A" : score >= 80 ? "B" : "C";</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">Nullish coalescing (??):</p>
<div class="command-wrapper">
<div class="command">let name = null;
let displayName = name ?? "אורח"; // "אורח"
let count = 0;
let value = count ?? 10; // 0 (לא 10!)
// ?? בודק רק null/undefined, לא 0 או false</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">Optional chaining (?.):</p>
<div class="command-wrapper">
<div class="command">let user = { name: "Alice" };
console.log(user?.address?.city); // undefined (לא שגיאה!)
// ללא optional chaining
// console.log(user.address.city); // ❌ שגיאה!</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
</section>
<!-- מחרוזות -->
<section id="strings" class="section">
<h2 class="section-title">מחרוזות (Strings)</h2>
<div class="note">
<div class="note-title">💡 עבודה עם טקסט</div>
<strong>מחרוזת</strong> - רצף של תווים (טקסט).<br>
<strong>3 דרכים ליצור:</strong> 'single', "double", `backtick`<br>
<strong>Template Literals</strong> (backticks) - המודרני והנוח ביותר!<br>
<strong>Immutable</strong> - לא ניתן לשנות מחרוזת, רק ליצור חדשה.<br>
<strong>טיפ:</strong> מחרוזות ב-JS הן אובייקטים עם מתודות רבות!
</div>
<div class="command-group">
<h3 class="command-title">יצירת מחרוזות</h3>
<p class="description">Template Literals - המומלץ:</p>
<div class="command-wrapper">
<div class="command">let name = "Alice";
let age = 25;
// Template literal עם ${} לשילוב משתנים
let message = `שלום, ${name}! אתה בן ${age}.`;
// מחרוזת מרובת שורות
let multiline = `שורה ראשונה
שורה שנייה
שורה שלישית`;
// ביטויים בתוך ${}
let result = `2 + 2 = ${2 + 2}`; // "2 + 2 = 4"</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>
<div class="command-group">
<h3 class="command-title">מתודות מחרוזת</h3>
<p class="description">אורך וגישה:</p>
<div class="command-wrapper">
<div class="command">let str = "JavaScript";
str.length; // 10 (אורך)
str[0]; // "J" (תו ראשון)
str[str.length - 1]; // "t" (תו אחרון)
str.charAt(4); // "S"</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">שינוי רישיות:</p>
<div class="command-wrapper">
<div class="command">let text = "Hello World";
text.toUpperCase(); // "HELLO WORLD"
text.toLowerCase(); // "hello world"</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">חיפוש:</p>
<div class="command-wrapper">
<div class="command">let str = "Hello World";
str.includes("World"); // true
str.startsWith("Hello"); // true
str.endsWith("World"); // true
str.indexOf("o"); // 4 (מיקום ראשון)
str.lastIndexOf("o"); // 7 (מיקום אחרון)</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">חיתוך והחלפה:</p>
<div class="command-wrapper">
<div class="command">let str = "JavaScript";
str.slice(0, 4); // "Java"
str.slice(4); // "Script"
str.slice(-6); // "Script" (מהסוף)
str.substring(0, 4); // "Java"
str.replace("Java", "Type"); // "TypeScript"
str.replaceAll("a", "A"); // "JAvaScript" → "JAvAScript"</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">פיצול וחיבור:</p>
<div class="command-wrapper">
<div class="command">let csv = "apple,banana,orange";
let fruits = csv.split(","); // ["apple", "banana", "orange"]
let words = ["Hello", "World"];
let sentence = words.join(" "); // "Hello World"</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
<p class="description">הסרת רווחים:</p>
<div class="command-wrapper">
<div class="command">let str = " Hello World ";
str.trim(); // "Hello World"
str.trimStart(); // "Hello World "
str.trimEnd(); // " Hello World"</div>
<button class="copy-btn" onclick="copyCommand(this)"></button>
</div>
</div>