title: how does a browser know if a javascript is from webpage or a client user has written them?
body: <p>javacript can be served to browsers that comes from server. but we can also write javascript code in the browser console.  so my question is how does a browser know that javascript is written by end user or it has come through webpage. is there some sort of ownership mechanism or stack implementation?</p>
  <p><strong>can i perform xss attack from brower console. if not then why?</strong></p>
  <p>i have just encountered a situation where a function was not defined inside a webpage script so throwing error. then i defined that function in browser console and then error changed to something else. (the whole code was written by me, website was mine too. but on a proper domain and is in production)</p>