Q:

add properties to function in JS

I'm new to Javascript, still struggling in understanding what a function really is. From my understanding. an object in JS is like:
let person= {
 name: "Tom",
 age: 20,
};

and we can add properties as:
person.number = 1234

so the person object will be like:
{
  name: "Tom",
  age: 20,
  number: 1234
}

and now I have a function as:
function Person(name, age){
  this.name = name,
  this.age = age
}

below is my questions:
Q1.  when we add a new property as:
Person.number = 1234;

does it mean that JS will modify the Person function internally as
function Person(name, age){
  this.name = name,
  this.age = age,
  this.number = 1234
}

is my understanding correct, I can only think of this way, otherwise how could you add a new property to a function?

A:

No, this in Person is not Person itself, it's a (hidden) argument that is passed to it, just like name or age. When you add a property to the function itself, it doesn't affect this in any way.

function Person(name, age) {
  this.name = name;
  this.age = age;
}
Person.number = 1234;

console.log(new Person('Joe', 22)); // no "number" here

An exception of this rule is the special prototype property, which does affect this when you use the function as a constructor (new ...()):

function Person(name, age) {
  this.name = name;
  this.age = age;
}
Person.number = 1234;

console.log(new Person('Joe', 22)); // no "number"

Person.prototype = {number: 5678};

console.log(new Person('Joe', 22)); // has "number"!

Otherwise, a function is an object in javascript, and you can manipulate it like any other object. 

function foo() {}

Object.assign(foo, {'bar': 123, 'baz': 456});

console.log(foo.bar);
console.log(Object.keys(foo));

