JavaScript Tutorial For Beginners #24 - Strings

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • Hey all, so far we've looked at two data types in JavaScript - Boolean types (true or false) and number types. In this tutorial I want to talk about a third data type - strings. Strings are essentially a string of characters, be them numbers to make a phone number, or letters to make a word or phrase, or even a combo of both.
    Strings have a lot of methods (built in functions) you can call on them, and we'll look at a few of them in this tutorial too.
    As always, if you have any questions, just fire away :).
    SUBSCRIBE TO CHANNEL - / @netninja
    ========== JavaScript for Beginners Playlist ==========
    • JavaScript Tutorials f...
    ========== CSS for Beginners Playlist ==========
    • CSS Tutorials For Begi...
    ========== HTML for Beginners Playlist ==========
    • HTML Tutorials For Beg...
    ========== The Net Ninja ============
    For more front-end development tutorials & to black-belt your coding skills, head over to - / @netninja or thenetninja.co.uk
    ========== Social Links ==========
    Twitter - @TheNetNinja - / thenetninjauk

ความคิดเห็น • 45

  • @ameedsayeh7481
    @ameedsayeh7481 7 ปีที่แล้ว +81

    "abc" is greater than "Bcd" because the capital letters comes first in the ASCII Table then the small letters
    so that "a" value in ASCII = 97
    while "B" = 66
    97 > 66
    ...
    Really, really thanks for your tutorials.
    You're great

    • @josei.lastra9689
      @josei.lastra9689 7 ปีที่แล้ว +4

      true

    • @thewebmaster312
      @thewebmaster312 7 ปีที่แล้ว +2

      I don't understand

    • @ameedsayeh7481
      @ameedsayeh7481 7 ปีที่แล้ว +4

      when comparing letters they're converted to their ascii numeric value
      check this table
      www.asciitable.com/

    • @petes4620
      @petes4620 5 ปีที่แล้ว +1

      This is utf-8 it is not converting anything to ascii, just to clarify to not confuse others

    • @bersi3306
      @bersi3306 2 ปีที่แล้ว +1

      Yes, is not "stupid" at all. Coming from C let appear JS like a piece of cake ;)

  • @joshuagerloff4065
    @joshuagerloff4065 5 ปีที่แล้ว +6

    I just wanted to let you know your videos are so incredbily useful! I am in the middle of a career change and start a coding camp for web development next week. I'm very excited for it and you have really helped me learn the fundamentals! Thank you so much!

    • @NetNinja
      @NetNinja  5 ปีที่แล้ว

      Awesome, thank you and good luck with everything :)

  • @vuja92
    @vuja92 7 ปีที่แล้ว +5

    Thanks Man! I begin to learn and I must say that your videos are so helpful!! :)

  • @meostyles
    @meostyles 3 ปีที่แล้ว +2

    I think the uppercase letters being before lowercase comes from their Unicode values rather than JavaScript, and I guess a way to remember it is that you'd always write a capital letter before lowercase letters which come after it.

  • @iashish7818
    @iashish7818 ปีที่แล้ว

    still watching and learning from this video in 2023, really appreciate your work

  • @brocklesnarufcchamp1
    @brocklesnarufcchamp1 6 ปีที่แล้ว +19

    var fromMe = "Thanks, mate!"
    document.write(fromMe.repeat(10));

  • @yaswanthmareedu3474
    @yaswanthmareedu3474 6 ปีที่แล้ว +5

    "abc" is greater than "Bcd" because of their ascii values
    ascii value of a=97
    ascii value of B=66
    66

  • @MsSuis
    @MsSuis 7 ปีที่แล้ว

    Capital letters have smaller value than lower letters. So while a < b returns TRUE, a < B returns FALSE.... If it helps to anyone, I put it to my mind like this, imagine you are assigning numbers, starting with the UPPERCASE alphabet, and we contunied assigning numbers for the lowercase charachters. So A 1, B 2, C 3.......Z 26, a 27, b 28, c 29..... So in that case Ben Lim's comment below makes more sense. And also as Ameed mentioned in his comment, but if you dont want to check ascii value. This could be a good way to keep it in mind.

  • @kel8720
    @kel8720 6 ปีที่แล้ว

    What is the website you referred to with the other methods on strings you didn't include it in your description? Thanks in advance these videos are great!

  • @joshrochon6243
    @joshrochon6243 7 ปีที่แล้ว

    Totally get what you're saying, but in my opinion, I quite like that lowercase letters are greater than their capital letter counterparts. By now camel case has become embedded in my head wherein lowercase always precede uppercase e.g., camelCaseLetters. Maybe this will help other people remember as well :)

  • @a1do255
    @a1do255 5 ปีที่แล้ว

    Instead of typing myString = 'I\'m a "fun" string' and having to deal with the escape character, single and or double quotes you could type myString = "I’m a “fun” string" provided that the used font includes the typographically correct symbols for apostrophe and quotation marks. How to enter these symbols depends on the operating system used. You can look it up online how to do that.

  • @pankierownik7987
    @pankierownik7987 7 ปีที่แล้ว +4

    Sound of your keyboard is very nice :D. Great work dude.

  • @harendrasinghpratap
    @harendrasinghpratap 6 ปีที่แล้ว

    abc>Bcd Because ASCII Code value of "a" is greater than "B".

  • @aakashgupta4476
    @aakashgupta4476 3 ปีที่แล้ว +1

    var explanation = great;
    console.log(explanation);

  • @fuad7258
    @fuad7258 3 ปีที่แล้ว

    ohh joss !

  • @EricCartmanFTW
    @EricCartmanFTW 7 ปีที่แล้ว

    In case anyone didn't know, when comparing single alphabets (z or Z) has the highest value. With lower case having the highest value. Try this out in console:
    e.g 1
    var a = "z"
    var b = "a"
    a > b = true
    e.g 2
    var a = "Z"
    var b = "A"
    a > b = true
    var a = "z"
    var b = "ABCDE"
    a > b = true

    • @tjs4278
      @tjs4278 6 ปีที่แล้ว

      Ben Lim its based on their ascii values
      Check the table

  • @peteplevnjak8323
    @peteplevnjak8323 8 ปีที่แล้ว

    Do you use books or documentation ?

  • @chito510_
    @chito510_ 6 ปีที่แล้ว

    8:00
    Why did you put .toLowerCase with string1 if the string is already lower case?
    Just curious.

    • @AntNews1
      @AntNews1 6 ปีที่แล้ว

      lets just say you did not know what var string1 was going to be, you would use that so it will not matter if the user puts capson or off bc everything will be turned into lower case

  • @ishwaryap9870
    @ishwaryap9870 6 ปีที่แล้ว +2

    for IndexOf - Index is starting from 0 , am I right?

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว +2

      Correct :)

    • @nishantnimish7825
      @nishantnimish7825 6 ปีที่แล้ว

      Yes...the net ninja spelled it incorrectly...he started from 1

  • @thewebmaster312
    @thewebmaster312 7 ปีที่แล้ว

    +thenetninja What line of code will give you a random number between 1 and 30 (for example) in JavaScript?

    • @Bartekk8812
      @Bartekk8812 7 ปีที่แล้ว +1

      Unfortunately you have to create your own function:
      function getRand (min, max) {
      return Math.floor(Math.random() * (max - min + 1)) + min;
      }
      And for number between 1 and 30 you call this function like this: getRand(1, 30);

    • @silentdisposition
      @silentdisposition 4 ปีที่แล้ว

      // returns random integers between 1 and 9
      document.write(Math.floor(Math.random() * 10));

  • @windowsclip6244
    @windowsclip6244 3 ปีที่แล้ว

    how to display a variable inside quotation mark in JS

  • @pragun1993
    @pragun1993 5 ปีที่แล้ว +1

    "abc" < "Bcd" is true not because javascript or any other language is stupid. It is because of ASCII value comparison of literals in which lower case are marked higher.

  • @peteplevnjak8323
    @peteplevnjak8323 8 ปีที่แล้ว +1

    I noticed that U use MDN

  • @artokilponen6989
    @artokilponen6989 6 ปีที่แล้ว +6

    "I ain't not no undummy"
    -Homer Simpson

  • @JashonMichael
    @JashonMichael 2 หลายเดือนก่อน +1

    The way you said stupid😅

  • @czescwszystkimniemam2528
    @czescwszystkimniemam2528 6 ปีที่แล้ว +2

    there is always one unlike ... some mad ex-gf ? :D

  • @MustafaBirsoz
    @MustafaBirsoz 3 ปีที่แล้ว

    whaa

  • @nashwanabdullah2234
    @nashwanabdullah2234 6 ปีที่แล้ว +1

    i need this songs

  • @DedCesar
    @DedCesar ปีที่แล้ว

    I’m crying

  • @iamtafara
    @iamtafara 6 ปีที่แล้ว

    ok my friend thats not a backslash,, thats a fowardslash,,

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว +4

      Haha yeah, my mistake XD

  • @DonXone
    @DonXone 6 ปีที่แล้ว

    Mr.Ninja none of the above worked, only .indexOf()