Ana sayfa Genel Javascript – Constructor ve This

Javascript – Constructor ve This

2407
218
PAYLAŞ

Herkese Merhaba,

Bu yazımda Javascriptte obje oluşturmak için kullanılan yapıcı metodlardan (constructor) ve this anahtar kelimesinden bahsedeceğim.

Öncelikle Javascriptte bir obje oluşturmak için en ilkel yöntem olan Object Literalleri kullanabiliriz.

Ancak bu yöntemle biz her bir objemizin değerini tekrar tekrar başlatmak durumunda kalıyoruz. Eğer biz bu yapıdan yüzlerce obje oluşturmak istersek, çok sayıda kod yazmamız gerekiyor.

Ancak Javascriptte diğer dillerde olduğu gibi constructorlarımızı yazıp bu constructorlara verilen değerler doğrultusunda bir çok obje oluşturabiliriz.

Constructor (Yapıcı Metod)

Constructorların kullanımı oldukça kolaydır. Şimdi örneğimize bakalım.

Burada ne yaptık ? Bir tane constructor oluşturduk ve new anahtar kelimesiyle bu constructor’ı kullanarak 2 tane objemizi oluşturduk.

Peki buradaki this anahtar kelimesinin anlamı nedir ?

this anahtar kelimesi

this anahtar kelimesi üzerinde bulunduğumuz objeyi simgeler ve this.property_name ve this.method_name ifadeleri o anki objemizin özelliklerini ve metodlarını vurgular.

this’in ne anlama geldiğini biraz daha iyi anlamak için isterseniz constructor’ın içinde konsola yazdırmaya çalışalım.

Çıktıya bakacak olursak, this’i konsola yazdırdığımız zaman hangi objenin içindeysek o objenin özellikleri ve metodları,yani en kısa ifadeyle o objenin konsola yazıldığını görebiliriz.

Bir de son olarak Global Scopeta this anahtar kelimesini yazdırdığımız zaman consoleda gördüğümüz objeye bakalım.

Global Scopeta window objesinin içinde olduğumuz için konsola bu objemiz yazılmış oldu. Web sayfalarımızda istersek alert() mesajlarımızı this üzerinden de kullanabiliriz. Çünkü alert() window objesinin bir metodudur.

Bir sonraki yazımızda görüşmek dileğiyle!

Mustafa Murat Coşkun

218 YORUMLAR

  1. Fantastic beat ! I would like to apprentice even as you amend your web site, how could i subscribe for a weblog site? The account helped me a acceptable deal. I were a little bit acquainted of this your broadcast offered brilliant transparent idea

  2. I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…

  3. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  4. I got this website from my buddy who informed me concerning this website and at the moment this time I am visiting this
    web page and reading very informative articles at this place.

  5. Attractive component of content. I just stumbled upon your site and in accession capital to claim that I get actually loved account your blog posts. Any way I’ll be subscribing in your augment and even I achievement you get right of entry to constantly quickly.

  6. Wonderful website you have here but I was curious about if you knew of any message boards that cover the same topics talked about here? I’d really like to be a part of group where I can get feedback from other knowledgeable people that share the same interest. If you have any recommendations, please let me know. Thanks a lot!

  7. Hello I am so thrilled I found your blog, I really found you by error, while I was researching on Yahoo for something else, Nonetheless I am here now and would just like to say many thanks for a tremendous post and a all round exciting blog (I also love the theme/design), I don’t have time to browse it all at the moment but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the superb work.

  8. Thanks for another great article. Where else could anybody get that kind of info in such a perfect way of writing? I’ve a presentation next week, and I’m on the look for such info.

  9. There are some interesting closing dates in this article however I don’t know if I see all of them center to heart. There may be some validity but I will take maintain opinion till I look into it further. Good article , thanks and we would like extra! Added to FeedBurner as nicely

  10. Just want to say your article is as amazing. The clarity for your put up is simply cool and i
    can think you’re a professional in this subject. Fine with your permission let me to grasp your feed to
    stay updated with coming near near post. Thank you one million and please carry on the rewarding
    work.

  11. Excellent read, I just passed this onto a friend who was doing a little research on that. And he actually bought me lunch since I found it for him smile So let me rephrase that: Thank you for lunch! “Feeling passionate about something is like getting a peak at your soul smiling back at you.” by Amanda Medinger.

  12. Hello great blog! Does running a blog such as
    this take a large amount of work? I’ve absolutely no understanding of computer programming however I had been hoping to start my own blog in the near future.
    Anyways, should you have any ideas or techniques for new blog owners please
    share. I know this is off subject but I just
    had to ask. Appreciate it!

  13. This design is spectacular! You definitely know how to keep a reader
    amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job.
    I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  14. F*ckin’ remarkable things here. I’m very glad to see your post. Thanks a lot and i am taking a look forward to touch you. Will you please drop me a mail?

  15. As I web-site possessor I believe the content material here is rattling great , appreciate it for your hard work. You should keep it up forever! Best of luck.

  16. F*ckin’ tremendous things here. I’m very satisfied to peer your post. Thank you so much and i’m having a look ahead to contact you. Will you please drop me a mail?

  17. I carry on listening to the newscast talk about getting boundless online grant applications so I have been looking around for the finest site to get one. Could you advise me please, where could i get some?

  18. Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.

  19. I have not checked in here for some time since I thought it was getting boring, but the last few posts are good quality so I guess I will add you back to my daily bloglist. You deserve it my friend 🙂

  20. What¦s Taking place i’m new to this, I stumbled upon this I have discovered It absolutely useful and it has aided me out loads. I’m hoping to contribute & help different customers like its helped me. Good job.

  21. Hi, I think your website might be having browser compatibility issues. When I look at your blog in Ie, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, terrific blog!

  22. Nice post. I used to be checking continuously this blog and I’m inspired! Extremely useful info specifically the closing phase 🙂 I take care of such information much. I was seeking this particular info for a very lengthy time. Thank you and best of luck.

  23. The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.

  24. The very crux of your writing while sounding agreeable originally, did not settle well with me personally after some time. Somewhere throughout the paragraphs you actually were able to make me a believer unfortunately only for a very short while. I nevertheless have a problem with your jumps in assumptions and you would do well to help fill in all those gaps. In the event that you actually can accomplish that, I would certainly be amazed.

  25. Thanks a lot for providing individuals with an extremely nice possiblity to discover important secrets from this web site. It is always very fantastic and packed with a lot of fun for me and my office acquaintances to search your blog at minimum three times in 7 days to read the fresh secrets you have got. Of course, I am also always pleased with your tremendous suggestions served by you. Certain 3 ideas in this posting are undoubtedly the best we’ve ever had.

  26. Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but instead of that, this is magnificent blog. A great read. I’ll certainly be back.

  27. I have been surfing on-line greater than three hours today, yet I by no means found any attention-grabbing article like yours. It is lovely price sufficient for me. In my view, if all website owners and bloggers made good content as you did, the net will probably be a lot more helpful than ever before.

  28. You can definitely see your skills within the paintings you write. The world hopes for more passionate writers such as you who are not afraid to mention how they believe. At all times go after your heart.

  29. The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.

  30. I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web savvy so I’m not 100 positive. Any tips or advice would be greatly appreciated. Many thanks

  31. you’re actually a just right webmaster. The web site loading speed is amazing. It sort of feels that you are doing any unique trick. Furthermore, The contents are masterpiece. you have done a excellent activity in this matter!

  32. excellent release, pretty beneficial. I wonder precisely why one other authorities of the field hardly understand the following. You must go on your current producing kumpulan youtube terbaru. I’m certain, you’ve a great readers’ starting presently!

  33. Yesterday, while I was at work, my sister stole my iPad and tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views. I know this is entirely off topic but I had to share it with someone!

  34. It is the best time to make some plans for the future and it is time to be happy. I have read this publish and if I may just I desire to counsel you some attention-grabbing issues or advice. Perhaps you can write next articles relating to this article. I want to read even more things about it!

  35. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get three e-mails with the same
    comment. Is there any way you can remove me from that service?

    Appreciate it!

  36. Thanks for the sensible critique. Me & my neighbor were just preparing to do a little research about this. We got a grab a book from our local library but I think I learned more from this post. I am very glad to see such excellent information being shared freely out there.

  37. I like this site very much, Its a very nice situation to read and obtain info . “There are two ways of spreading light to be the candle or the mirror that reflects it.” by Edith Newbold Jones Wharton.

  38. You probably ensure it is seem to be quite simple together with your speech however I in discovering this trouble to get really something that I feel I’d personally in no way recognize cara main trading saham. It kind of feels way too intricate as well as broad personally. I am looking forward to your following upload, I am going to attempt to get the hold of that!

  39. Please let me know if you’re looking for a author for your blog. You have some really good posts and I think I would be a good asset. If you ever want to take some of the load off, I’d love to write some material for your blog in exchange for a link back to mine. Please shoot me an e-mail if interested. Kudos!

  40. After examine a few of the blog posts in your web site now, and I actually like your means of blogging. I bookmarked it to my bookmark web site checklist and will probably be checking back soon. Pls check out my web page as properly and let me know what you think.

  41. Thank you for sharing excellent informations. Your website is very cool. I am impressed by the details that you?¦ve on this website. It reveals how nicely you understand this subject. Bookmarked this web page, will come back for more articles. You, my pal, ROCK! I found just the info I already searched all over the place and just could not come across. What a great web site.

  42. The next time I learn a weblog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, however I truly thought youd have one thing attention-grabbing to say. All I hear is a bunch of whining about one thing that you might fix if you happen to werent too busy on the lookout for attention.

  43. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what youre talking about, why throw away your intelligence on just posting videos to your site when you could be giving us something informative to read?

  44. I liked up to you will obtain carried out proper here. The sketch is tasteful, your authored subject matter stylish. however, you command get bought an impatience over that you want be turning in the following. sick unquestionably come more formerly again as precisely the similar nearly a lot regularly inside case you shield this increase.

  45. I do enjoy the manner in which you have presented this specific difficulty plus it really does give me some fodder for thought. Nonetheless, through just what I have observed, I simply just wish as the responses pile on that people today continue to be on issue and don’t start upon a soap box regarding some other news of the day. Yet, thank you for this exceptional piece and though I do not really agree with the idea in totality, I regard the point of view.

  46. Thanks for sharing excellent informations. Your site is so cool. I’m impressed by the details that you’ve on this blog. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found simply the info I already searched everywhere and just couldn’t come across. What a great site.

  47. Hello There. I found your blog using msn. This is a really well written article. I will make sure to bookmark it and come back to read more of your useful info. Thanks for the post. I will certainly return.

  48. Hello there, simply turned into alert to your blog via Google, and located that it’s truly informative. I’m going to watch out for brussels. I’ll be grateful in case you proceed this in future. Many people might be benefited out of your writing. Cheers!

  49. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  50. I precisely wanted to thank you so much yet again. I am not sure the things that I could possibly have implemented in the absence of those tips contributed by you directly on such a field. It has been a very horrifying crisis for me, however , being able to view this specialized mode you handled the issue made me to cry for fulfillment. I’m grateful for the service and as well , hope you are aware of a powerful job you happen to be accomplishing teaching many people through the use of your site. Probably you haven’t met any of us.

  51. of course like your web site but you need to check the spelling on quite a few of your posts. A number of them are rife with spelling issues and I find it very troublesome to tell the truth on the other hand I will definitely come again again.

  52. Please let me know if you’re looking for a article writer for your weblog. You have some really good posts and I think I would be a good asset. If you ever want to take some of the load off, I’d really like to write some content for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Thank you!

  53. Somebody essentially help to make seriously posts I would state. This is the first time I frequented your website page and thus far? I surprised with the research you made to create this particular publish incredible. Wonderful job!

  54. certainly like your web-site but you need to test the spelling on quite a few of your posts. Many of them are rife with spelling problems and I find it very troublesome to inform the truth then again I will surely come again again.

  55. Howdy very cool blog!! Man .. Beautiful .. Amazing .. I will bookmark your blog and take the feeds additionallyKI am glad to seek out numerous helpful info right here in the put up, we’d like develop more techniques in this regard, thanks for sharing. . . . . .

  56. Hi there very cool web site!! Man .. Excellent .. Wonderful .. I will bookmark your site and take the feeds additionally…I am happy to search out a lot of helpful information right here in the submit, we’d like work out more techniques on this regard, thank you for sharing. . . . . .

  57. Thank you so much for providing individuals with a very terrific possiblity to read in detail from this blog. It’s usually very pleasurable and as well , jam-packed with a great time for me and my office co-workers to visit your blog on the least 3 times in one week to see the newest things you have got. Of course, I’m usually contented with all the good creative concepts you serve. Some 1 facts in this posting are particularly the best I’ve had.

  58. Simply want to say your article is as astonishing. The clarity in your submit is just excellent and that i can think you’re an expert in this subject. Fine with your permission allow me to grasp your feed to keep updated with coming near near post. Thanks 1,000,000 and please carry on the rewarding work.

  59. Very interesting info !Perfect just what I was searching for! “If you bungle raising your children, I don’t think whatever else you do matters.” by Jacqueline Lee Bouvier Kennedy Onassis.

  60. Somebody essentially help to make seriously articles I would state. This is the first time I frequented your website page and thus far? I surprised with the research you made to create this particular publish incredible. Excellent job!

  61. Great weblog right here! Additionally your web site quite a bit up fast! What web host are you the use of? Can I get your associate hyperlink on your host? I wish my site loaded up as quickly as yours lol

  62. Pretty nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed surfing around your blog posts. In any case I’ll be subscribing to your rss feed and I hope you write again soon!

  63. Hello there! I could have sworn I’ve been to this website before but after checking through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back often!

  64. Everything published was very reasonable. However, what about this?
    what if you composed a catchier post title?
    I am not saying your information isn’t solid., however suppose you
    added a post title that grabbed people’s attention? I mean Javascript – Constructor ve This Nedir ?
    | Yazılım Bilimi is a little plain. You ought to look at Yahoo’s home page and watch how they create
    news titles to grab people to open the links. You might add a video or a related picture or two to grab people interested about what you’ve got to say.
    In my opinion, it would make your posts a little bit more interesting.

  65. With havin so much content and articles do you ever run into any problems of plagorism or copyright infringement? My site has a lot of completely unique content I’ve either created myself or outsourced but it looks like a lot of it is popping it up all over the web without my agreement. Do you know any ways to help reduce content from being stolen? I’d truly appreciate it.

  66. I’m still learning from you, while I’m trying to reach my goals. I absolutely liked reading all that is posted on your site.Keep the stories coming. I liked it!

  67. What i do not realize is actually how you are now not actually much more neatly-appreciated than you might be now. You’re very intelligent. You understand thus significantly in the case of this subject, made me in my view imagine it from numerous numerous angles. Its like men and women don’t seem to be involved until it’s one thing to do with Girl gaga! Your own stuffs great. Always maintain it up!

  68. After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.

  69. Hello, i believe that i saw you visited my site thus i came to “go back the desire”.I am trying to in finding things to enhance my web site!I suppose its good enough to make use of some of your ideas!!

  70. I’m curious to find out what blog platform you happen to be using? I’m having some small security issues with my latest website and I would like to find something more safe. Do you have any suggestions?

  71. I’m usually to running a blog and i actually recognize your content. The article has actually peaks my interest. I am going to bookmark your site and maintain checking for brand spanking new information.

  72. That is the proper blog for anyone who needs to find out about this topic. You understand a lot its virtually laborious to argue with you (not that I really would want…HaHa). You undoubtedly put a new spin on a subject thats been written about for years. Great stuff, just nice!

  73. Hello. Very interesting content but it’s hard to find yazilimbilimi.org in google.
    You are out of google’s top 10, so you can’t expect big traffic.
    You need hi quality backlinks. And you can get them even for
    free, just search in google: wrastain’s tools

  74. Hello There. I discovered your blog the usage of msn. This is a really smartly written article. I’ll be sure to bookmark it and come back to learn more of your useful information. Thank you for the post. I’ll certainly return.

  75. Appreciating the time and effort you put into your blog and detailed information you offer. It’s nice to come across a blog every once in a while that isn’t the same old rehashed material. Excellent read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

  76. Somebody essentially assist to make significantly posts I might state. That is the first time I frequented your website page and up to now? I surprised with the analysis you made to make this particular publish incredible. Wonderful activity!

  77. I feel this is one of the most vital info for me. And i am glad studying your article. However want to commentary on some common things, The site style is great, the articles is in reality great : D. Good process, cheers

  78. My husband and i have been so more than happy that John could carry out his basic research while using the ideas he received through your weblog. It’s not at all simplistic to just find yourself making a gift of ideas that many people today may have been making money from. We fully understand we now have the website owner to thank for that. Most of the illustrations you made, the straightforward site menu, the friendships you can help foster – it’s got most amazing, and it’s really making our son and our family understand the subject matter is pleasurable, and that is incredibly essential. Thank you for all the pieces!

  79. you are really a good webmaster. The site loading speed is amazing. It seems that you are doing any unique trick. Moreover, The contents are masterpiece. you have done a magnificent job on this topic!

  80. Very good blog! Do you have any hints for aspiring writers? I’m hoping to start my own website soon but I’m a little lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally confused .. Any ideas? Thank you!

  81. Hiya, I am really glad I’ve found this information. Today bloggers publish just about gossips and web and this is actually annoying. A good website with exciting content, this is what I need. Thank you for keeping this website, I’ll be visiting it. Do you do newsletters? Can’t find it.

  82. I was wondering if you ever considered changing the structure of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?

BİR CEVAP BIRAK

Please enter your comment!
Please enter your name here