How to document as parameter default value

I just want know why,please anybody give give me some hint?

const getElement = (selector, scope = window.document) => scope.querySelector(selector);

const getElement = (selector, scope) => (scope || window.document).querySelector(selector);

will catch error querySelector is not a function when called it in DOMContentLoaded block. Object window should already exist.

// document.addEventListener("DOMContentLoaded", e => {
document.addEventListener("turbolinks:load", () => {
  // const $table = getElement("table");
  const $table = document.querySelector("table");

  // const $trees = getElement("[data-tree]", $table);
  const $trees = getElement("[data-tree]");
});
const getElement = (selector, scope = window.document) => scope.querySelector(selector);

window.addEventListener("DOMContentLoaded", e => {

  let aa = getElement('[data-tree]')

  console.log( aa.textContent )

  });
.as-console-wrapper { max-height: 100% !important; top: 0; }
.as-console-row         { background-color: yellow; }
.as-console-row::after  { display:none !important; }
<div   data-tree="xyz" >hello world</div>

61 thoughts on “How to document as parameter default value”

  1. I’m not sure why but this weblog is loading extremely slow for me.
    Is anyone else having this issue or is it a issue
    on my end? I’ll check back later on and see if the
    problem still exists.

    Reply
  2. Hi, I do believe this is a great site. I stumbledupon it 😉 I’m going to revisit yet again since i
    have bookmarked it. Money and freedom is the greatest way to change, may
    you be rich and continue to guide other people.

    Reply
  3. I really like your blog.. very nice colors & theme.
    Did you create this website yourself or did you
    hire someone to do it for you? Plz reply as I’m looking to construct
    my own blog and would like to know where u got this from.
    thank you

    Reply
  4. Hi there! This article could not be written much better!

    Looking at this post reminds me of my previous roommate!

    He constantly kept talking about this. I’ll forward this
    post to him. Pretty sure he’s going to have a very good read.
    Many thanks for sharing!

    Reply
  5. Thank you for some other wonderful post. Where else could anybody get that type of info in such an ideal
    method of writing? I’ve a presentation subsequent week, and I am
    at the look for such info.

    Reply
  6. I blog quite often and I really thank you for your information. This article has really peaked my interest.
    I will bookmark your website and keep checking for new details about once per week.
    I subscribed to your Feed as well.

    Reply
  7. I am really impressed with your writing skills as well as with the
    layout on your blog. Is this a paid theme or did you customize it yourself?

    Anyway keep up the excellent quality writing,
    it’s rare to see a nice blog like this one these
    days.

    Reply
  8. Hey! Someone in my Facebook group shared this site with us so I
    came to take a look. I’m definitely enjoying the information.
    I’m bookmarking and will be tweeting this to my followers!
    Exceptional blog and outstanding style and
    design.

    Reply
  9. Greetings from California! I’m bored at work so I
    decided to browse your blog on my iphone during lunch break.
    I really like the knowledge you present here and can’t wait
    to take a look when I get home. I’m surprised at how quick your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyhow, awesome blog!

    Reply
  10. My spouse and I stumbled over here by a different website
    and thought I should check things out. I like what I see so now i am following you.
    Look forward to finding out about your web page repeatedly.

    Reply
  11. Thanks for the marvelous posting! I really enjoyed reading it, you are a great author.
    I will make sure to bookmark your blog and will come back very soon. I want
    to encourage you to definitely continue your great writing, have
    a nice afternoon!

    Reply
  12. I must thank you for the efforts you’ve put in penning this site.
    I really hope to see the same high-grade content by you in the future as
    well. In fact, your creative writing abilities has motivated
    me to get my own, personal site now 😉

    Reply
  13. Hey there! This post couldn’t be written any better!
    Reading through this post reminds me of my good old room mate!
    He always kept chatting about this. I will forward this page to
    him. Pretty sure he will have a good read. Thanks for sharing!

    Reply
  14. Hello! I could have sworn I’ve been to this blog before but after reading through some of the post I realized it’s new to me.
    Anyhow, I’m definitely delighted I found it and I’ll be bookmarking and checking back often!

    Reply
  15. Oh my goodness! Awesome article dude! Thank you so much,
    However I am experiencing troubles with your RSS. I don’t know why I can’t
    subscribe to it. Is there anyone else getting
    similar RSS issues? Anybody who knows the answer can you kindly respond?
    Thanx!!

    Reply
  16. Good day! This post couldn’t be written any better!
    Reading this post reminds me of my old room mate!
    He always kept talking about this. I will forward this post
    to him. Fairly certain he will have a good read. Thank you for sharing!

    Reply
  17. I do not know if it’s just me or if perhaps everybody else experiencing problems with your blog.
    It appears as if some of the text within your posts are running off the screen. Can someone else please comment and let me know if this is
    happening to them as well? This could be a issue with
    my internet browser because I’ve had this happen before.
    Many thanks

    Reply
  18. Hello just wanted to give you a quick heads up. The text in your article seem to
    be running off the screen in Internet explorer. I’m not sure if
    this is a format issue or something to do with internet browser compatibility but I figured I’d post to let you
    know. The design and style look great though! Hope you get the issue solved soon. Many thanks

    Reply
  19. Greetings from Los angeles! I’m bored at work so I decided to browse your site on my iphone during lunch break.
    I love the info you provide here and can’t wait to take a look when I get home.
    I’m shocked at how fast your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyhow, amazing site!

    Reply
  20. Does your website have a contact page? I’m having a tough time locating it but,
    I’d like to shoot you an email. I’ve got some ideas for your blog you might be interested in hearing.
    Either way, great site and I look forward to seeing it develop over time.

    Reply
  21. Very great post. I just stumbled upon your weblog and wanted to say that
    I’ve truly enjoyed surfing around your blog posts. In any case I’ll be subscribing in your feed and
    I am hoping you write again soon!

    Reply
  22. You really make it seem so easy with your presentation but I find this topic to be really something that I think
    I would never understand. It seems too complicated and very broad for me.
    I am looking forward for your next post, I will try to get the hang of it!

    Reply
  23. Thanks for one’s marvelous posting! I quite
    enjoyed reading it, you could be a great
    author.I will remember to bookmark your blog and may come back in the foreseeable future.
    I want to encourage yourself to continue your great writing,
    have a nice afternoon!

    Reply
  24. I absolutely love your blog and find nearly all of your post’s to be what precisely I’m looking for.
    can you offer guest writers to write content available for you?
    I wouldn’t mind creating a post or elaborating on many of the subjects
    you write with regards to here. Again, awesome
    website!

    Reply
  25. Thanks for your personal marvelous posting! I really enjoyed reading it,
    you will be a great author. I will ensure that I bookmark your blog and
    will eventually come back from now on. I want
    to encourage yourself to continue your great job, have a
    nice afternoon!

    Reply

Leave a Comment