textures unit bind uniform sampler2D from learopengl

Hi Everyone,
I rencently learn OpenGL from LearnOpenGL - Textures.
When I get to the chapter about Texture. I got a confused problem.

This is the example I checked. As you can see from github, I picked out the line from 146 to 149. I think it will bind the Texture unit to correct sampler in fragment script. 
If I make "texture1" in glUniform1i(glGetUniformLocation(ourShader.ID, "texture1"), 0);  to "texture1" or something else which is not correct with fragment script. I will get a pure “awesomeface.png”.
But the fact is not, I still got a box with a smile. I don't know, seems I have no need to call the function     glUniform1i(glGetUniformLocation(ourShader.ID, "texture1"), 0);
So, I remove that. I still got a box with a smile. That confused me. Can someone help me out? Thanks

Plus with the post, If I didn’t replace GL_TEXTURE0 with GL_TEXTURE0. That’s correct with my expectations. Why ??? :tired:

    // either set it manually like so:
    glUniform1i(glGetUniformLocation(ourShader.ID, "texture1"), 0);
    // or set it via the texture class
    ourShader.setInt("texture2", 1);

All uniform values which are not initialized in the shader text itself are initialized by the system to be 0 (or false for bools). That includes sampler uniforms.

Since you just so happen to be setting that uniform value to 0, the default just so happens to be fine. In this specific case.

But you should never rely on this. Always explicitly set stuff your code depends on.

Thanks, your answer can explain this phenomenon. And I found a reference at https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_uniform_buffer_object.txt. Thanks again.

[QUOTE=Alfonse Reinheart;1293400]All uniform values which are not initialized in the shader text itself are initialized by the system to be 0 (or false for bools). That includes sampler uniforms.

Since you just so happen to be setting that uniform value to 0, the default just so happens to be fine. In this specific case.

But you should never rely on this. Always explicitly set stuff your code depends on.[/QUOTE]